QString("Capture failed"), _1));
break;
+ case SigSession::AwaitingTrigger:
case SigSession::Running:
_session.stop_capture();
break;
void MainWindow::capture_state_changed(int state)
{
- _sampling_bar->set_sampling(state != SigSession::Stopped);
+ _sampling_bar->set_capture_state((pv::SigSession::capture_state)state);
}
void MainWindow::view_selection_changed()
void SigSession::set_capture_state(capture_state state)
{
lock_guard<mutex> lock(_sampling_mutex);
+ const bool changed = _capture_state != state;
_capture_state = state;
- capture_state_changed(state);
+ if(changed)
+ capture_state_changed(state);
}
/**
signals_changed();
}
+bool SigSession::is_trigger_enabled() const
+{
+ assert(_sdi);
+ for (const GSList *l = _sdi->probes; l; l = l->next) {
+ const sr_probe *const p = (const sr_probe *)l->data;
+ assert(p);
+ if (p->trigger && p->trigger[0] != '\0')
+ return true;
+ }
+
+ return false;
+}
+
void SigSession::load_thread_proc(const string name,
function<void (const QString)> error_handler)
{
return;
}
- set_capture_state(Running);
+ set_capture_state(is_trigger_enabled() ? AwaitingTrigger : Running);
sr_session_run();
sr_session_destroy();
if (!_cur_logic_snapshot)
{
+ set_capture_state(Running);
+
// Create a new data snapshot
_cur_logic_snapshot = shared_ptr<data::LogicSnapshot>(
new data::LogicSnapshot(logic));
if (!_cur_analog_snapshot)
{
+ set_capture_state(Running);
+
// Create a new data snapshot
_cur_analog_snapshot = shared_ptr<data::AnalogSnapshot>(
new data::AnalogSnapshot(analog));
public:
enum capture_state {
Stopped,
+ AwaitingTrigger,
Running
};
void update_signals();
+ bool is_trigger_enabled() const;
+
private:
/**
* Attempts to autodetect the format. Failing that
_configure_button(this),
_record_length_selector(this),
_sample_rate_list(this),
+ _icon_red(":/icons/status-red.svg"),
_icon_green(":/icons/status-green.svg"),
_icon_grey(":/icons/status-grey.svg"),
_run_stop_button(this)
_record_length_selector.setCurrentIndex(i);
}
- set_sampling(false);
+ set_capture_state(pv::SigSession::Stopped);
_configure_button.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/configure.png")));
return _record_length_selector.itemData(index).value<uint64_t>();
}
-void SamplingBar::set_sampling(bool sampling)
+void SamplingBar::set_capture_state(pv::SigSession::capture_state state)
{
- _run_stop_button.setIcon(sampling ? _icon_green : _icon_grey);
- _run_stop_button.setText(sampling ? "Stop" : "Run");
+ const QIcon *icons[] = {&_icon_grey, &_icon_red, &_icon_green};
+ _run_stop_button.setIcon(*icons[state]);
+ _run_stop_button.setText((state == pv::SigSession::Stopped) ?
+ tr("Run") : tr("Stop"));
}
void SamplingBar::update_sample_rate_selector()
#include <QToolBar>
#include <QToolButton>
+#include <pv/sigsession.h>
+
struct st_dev_inst;
class QAction;
uint64_t get_record_length() const;
- void set_sampling(bool sampling);
+ void set_capture_state(pv::SigSession::capture_state state);
signals:
void device_selected();
QDoubleSpinBox _sample_rate_value;
QAction *_sample_rate_value_action;
+ QIcon _icon_red;
QIcon _icon_green;
QIcon _icon_grey;
QToolButton _run_stop_button;