ui->setupUi(this);
_sampling_bar = new SamplingBar(this);
+ connect(_sampling_bar, SIGNAL(run_stop()), this,
+ SLOT(run_stop()));
addToolBar(_sampling_bar);
view = new SigView(session, this);
About dlg(this);
dlg.exec();
}
+
+void MainWindow::run_stop()
+{
+ session.start_capture(
+ _sampling_bar->get_selected_device(),
+ _sampling_bar->get_sample_rate());
+}
void on_actionOpen_triggered();
void on_actionAbout_triggered();
+
+ void run_stop();
};
#endif // MAINWINDOW_H
SamplingBar::SamplingBar(QWidget *parent) :
QToolBar("Sampling Bar", parent),
_device_selector(this),
- _sample_rate_list(this)
+ _sample_rate_list(this),
+ _run_stop_button(this)
{
+ connect(&_run_stop_button, SIGNAL(clicked()), this, SIGNAL(run_stop()));
connect(&_device_selector, SIGNAL(currentIndexChanged (int)),
this, SLOT(on_device_selected()));
_sample_rate_value.setDecimals(0);
_sample_rate_value.setSuffix("Hz");
+ _run_stop_button.setText("Run");
+
addWidget(&_device_selector);
_sample_rate_list_action = addWidget(&_sample_rate_list);
_sample_rate_value_action = addWidget(&_sample_rate_value);
+ addWidget(&_run_stop_button);
update_device_selector();
update_sample_rate_selector();
struct sr_dev_inst* get_selected_device() const;
uint64_t get_sample_rate() const;
+signals:
+ void run_stop();
+
private:
void update_device_selector();
void update_sample_rate_selector();
QAction *_sample_rate_list_action;
QDoubleSpinBox _sample_rate_value;
QAction *_sample_rate_value_action;
+
+ QToolButton _run_stop_button;
};
#endif // SAMPLINGBAR_H
}
}
+void SigSession::start_capture(struct sr_dev_inst *sdi,
+ uint64_t sample_rate)
+{
+ sr_session_new();
+ sr_session_datafeed_callback_add(dataFeedInProc);
+
+ if (sr_session_dev_add(sdi) != SR_OK) {
+ qDebug() << "Failed to use device.";
+ sr_session_destroy();
+ return;
+ }
+
+ uint64_t limit_samples = 10000;
+ if (sr_dev_config_set(sdi, SR_HWCAP_LIMIT_SAMPLES,
+ &limit_samples) != SR_OK) {
+ qDebug() << "Failed to configure time-based sample limit.";
+ sr_session_destroy();
+ return;
+ }
+
+ if (sr_dev_config_set(sdi, SR_HWCAP_SAMPLERATE,
+ &sample_rate) != SR_OK) {
+ qDebug() << "Failed to configure samplerate.";
+ sr_session_destroy();
+ return;
+ }
+
+ if (sr_session_start() != SR_OK) {
+ qDebug() << "Failed to start session.";
+ return;
+ }
+
+ sr_session_run();
+ sr_session_destroy();
+}
+
vector< shared_ptr<Signal> >& SigSession::get_signals()
{
return _signals;
void loadFile(const std::string &name);
+ void start_capture(struct sr_dev_inst* sdi, uint64_t sample_rate);
+
std::vector< boost::shared_ptr<Signal> >&
get_signals();