mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
Fix trigger issue @ DSO mode
This commit is contained in:
parent
5bd97eb8c2
commit
4cc02c8d78
@ -958,11 +958,28 @@ QSlider::groove:horizontal {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal:disabled {
|
||||
border: 1px solid #3A3939;
|
||||
height: 8px;
|
||||
background: #282727;
|
||||
margin: 2px 0;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QSlider::handle:horizontal {
|
||||
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0.0 silver, stop: 0.2 #a8a8a8, stop: 1 #727272);
|
||||
border: 1px solid #3A3939;
|
||||
width: 14px;
|
||||
width: 10px;
|
||||
height: 14px;
|
||||
margin: -4px 0;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QSlider::handle:horizontal:disabled {
|
||||
background: #4A4949;
|
||||
border: 1px solid #3A3939;
|
||||
width: 10px;
|
||||
height: 14px;
|
||||
margin: -4px 0;
|
||||
border-radius: 2px;
|
||||
@ -976,15 +993,33 @@ QSlider::groove:vertical {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QSlider::groove:vertical:disabled {
|
||||
border: 1px solid #3A3939;
|
||||
height: 8px;
|
||||
background: #403F3F;
|
||||
margin: 2px 0;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QSlider::handle:vertical {
|
||||
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 silver,
|
||||
stop: 0.2 #a8a8a8, stop: 1 #727272);
|
||||
border: 1px solid #3A3939;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
height: 10px;
|
||||
margin: 0 -4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QSlider::handle:vertical:disabled {
|
||||
background: #4A4949;
|
||||
border: 1px solid #3A3939;
|
||||
width: 14px;
|
||||
height: 10px;
|
||||
margin: 0 -4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QToolButton#MaximizeButton {
|
||||
background-color: transparent;
|
||||
border-left: 1px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
|
@ -200,7 +200,7 @@ void MathStack::calc_fft()
|
||||
_samplerate = 1.0;
|
||||
|
||||
// prepare _xn data
|
||||
const double offset = dsoSig->get_zeroValue();
|
||||
const double offset = dsoSig->get_zero_value();
|
||||
const double vscale = dsoSig->get_vDialValue() * dsoSig->get_factor() * DS_CONF_DSO_VDIVS / (1000*255.0);
|
||||
const uint16_t step = _snapshot->get_channel_num() * _sample_interval;
|
||||
const uint8_t *const samples = _snapshot->get_samples(0, _sample_num*_sample_interval-1, _index);
|
||||
|
@ -56,7 +56,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) :
|
||||
connect(position_spinBox, SIGNAL(valueChanged(int)), position_slider, SLOT(setValue(int)));
|
||||
connect(position_slider, SIGNAL(valueChanged(int)), this, SLOT(pos_changed(int)));
|
||||
|
||||
QLabel *holdoff_label = new QLabel(tr("Trigger Hold Off Time: "), _widget);
|
||||
QLabel *holdoff_label = new QLabel(tr("Hold Off Time: "), _widget);
|
||||
holdoff_comboBox = new QComboBox(_widget);
|
||||
holdoff_comboBox->addItem(tr("uS"), qVariantFromValue(1000));
|
||||
holdoff_comboBox->addItem(tr("mS"), qVariantFromValue(1000000));
|
||||
@ -71,6 +71,11 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) :
|
||||
connect(holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int)));
|
||||
connect(holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int)));
|
||||
|
||||
QLabel *margin_label = new QLabel(tr("Noise Sensitivity: "), _widget);
|
||||
margin_slider = new QSlider(Qt::Horizontal, _widget);
|
||||
margin_slider->setRange(0, 15);
|
||||
connect(margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int)));
|
||||
|
||||
|
||||
QLabel *tSource_labe = new QLabel(tr("Trigger Sources: "), _widget);
|
||||
QRadioButton *auto_radioButton = new QRadioButton(tr("Auto"));
|
||||
@ -137,6 +142,10 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) :
|
||||
gLayout->addWidget(holdoff_comboBox, 12, 2);
|
||||
gLayout->addWidget(holdoff_slider, 13, 0, 1, 4);
|
||||
|
||||
gLayout->addWidget(new QLabel(_widget), 14, 0);
|
||||
gLayout->addWidget(margin_label, 15, 0);
|
||||
gLayout->addWidget(margin_slider, 16, 0, 1, 4);
|
||||
|
||||
gLayout->setColumnStretch(3, 1);
|
||||
|
||||
layout->addLayout(gLayout);
|
||||
@ -174,10 +183,7 @@ void DsoTriggerDock::pos_changed(int pos)
|
||||
msg.mBox()->setIcon(QMessageBox::Warning);
|
||||
msg.exec();
|
||||
}
|
||||
|
||||
uint64_t sample_limit = _session.get_device()->get_sample_limit();
|
||||
uint64_t trig_pos = sample_limit * pos / 100;
|
||||
set_trig_pos(trig_pos);
|
||||
set_trig_pos(pos);
|
||||
}
|
||||
|
||||
void DsoTriggerDock::hold_changed(int hold)
|
||||
@ -205,6 +211,22 @@ void DsoTriggerDock::hold_changed(int hold)
|
||||
}
|
||||
}
|
||||
|
||||
void DsoTriggerDock::margin_changed(int margin)
|
||||
{
|
||||
int ret;
|
||||
ret = _session.get_device()->set_config(NULL, NULL,
|
||||
SR_CONF_TRIGGER_MARGIN,
|
||||
g_variant_new_byte(margin));
|
||||
if (!ret) {
|
||||
dialogs::DSMessageBox msg(this);
|
||||
msg.mBox()->setText(tr("Trigger Setting Issue"));
|
||||
msg.mBox()->setInformativeText(tr("Change trigger value sensitivity failed!"));
|
||||
msg.mBox()->setStandardButtons(QMessageBox::Ok);
|
||||
msg.mBox()->setIcon(QMessageBox::Warning);
|
||||
msg.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void DsoTriggerDock::source_changed()
|
||||
{
|
||||
int id = source_group->checkedId();
|
||||
@ -254,6 +276,27 @@ void DsoTriggerDock::device_change()
|
||||
|
||||
void DsoTriggerDock::init()
|
||||
{
|
||||
if (_session.get_device()->name().contains("virtual")) {
|
||||
foreach(QAbstractButton * btn, source_group->buttons())
|
||||
btn->setDisabled(true);
|
||||
foreach(QAbstractButton * btn, type_group->buttons())
|
||||
btn->setDisabled(true);
|
||||
holdoff_slider->setDisabled(true);
|
||||
holdoff_spinBox->setDisabled(true);
|
||||
holdoff_comboBox->setDisabled(true);
|
||||
margin_slider->setDisabled(true);
|
||||
return;
|
||||
} else {
|
||||
foreach(QAbstractButton * btn, source_group->buttons())
|
||||
btn->setDisabled(false);
|
||||
foreach(QAbstractButton * btn, type_group->buttons())
|
||||
btn->setDisabled(false);
|
||||
holdoff_slider->setDisabled(false);
|
||||
holdoff_spinBox->setDisabled(false);
|
||||
holdoff_comboBox->setDisabled(false);
|
||||
margin_slider->setDisabled(false);
|
||||
}
|
||||
|
||||
// TRIGGERPOS
|
||||
GVariant* gvar = _session.get_device()->get_config(NULL, NULL,
|
||||
SR_CONF_HORIZ_TRIGGERPOS);
|
||||
|
@ -55,11 +55,12 @@ public:
|
||||
void init();
|
||||
|
||||
signals:
|
||||
void set_trig_pos(quint64 trig_pos);
|
||||
void set_trig_pos(int percent);
|
||||
|
||||
private slots:
|
||||
void pos_changed(int pos);
|
||||
void hold_changed(int hold);
|
||||
void margin_changed(int margin);
|
||||
void source_changed();
|
||||
void type_changed();
|
||||
|
||||
@ -74,6 +75,8 @@ private:
|
||||
QSpinBox *holdoff_spinBox;
|
||||
QSlider *holdoff_slider;
|
||||
|
||||
QSlider *margin_slider;
|
||||
|
||||
QSpinBox *position_spinBox;
|
||||
QSlider *position_slider;
|
||||
|
||||
|
@ -54,6 +54,7 @@ MainFrame::MainFrame(DeviceManager &device_manager,
|
||||
_moving = false;
|
||||
_startPos = None;
|
||||
_freezing = false;
|
||||
_minimized = false;
|
||||
|
||||
// MainWindow
|
||||
_mainWindow = new MainWindow(device_manager, open_file_name, this);
|
||||
@ -114,6 +115,33 @@ MainFrame::MainFrame(DeviceManager &device_manager,
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void MainFrame::changeEvent(QEvent* event)
|
||||
{
|
||||
QFrame::changeEvent(event);
|
||||
QWindowStateChangeEvent* win_event = static_cast< QWindowStateChangeEvent* >(event);
|
||||
if(win_event->type() == QEvent::WindowStateChange) {
|
||||
if (win_event->oldState() & Qt::WindowMinimized) {
|
||||
if (_minimized) {
|
||||
readSettings();
|
||||
_minimized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainFrame::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QFrame::resizeEvent(event);
|
||||
if (isMaximized()) {
|
||||
hide_border();
|
||||
} else {
|
||||
show_border();
|
||||
}
|
||||
_titleBar->setRestoreButton(isMaximized());
|
||||
_layout->update();
|
||||
}
|
||||
|
||||
void MainFrame::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
_mainWindow->session_save();
|
||||
@ -162,6 +190,13 @@ void MainFrame::showMaximized()
|
||||
QFrame::showMaximized();
|
||||
}
|
||||
|
||||
void MainFrame::showMinimized()
|
||||
{
|
||||
_minimized = true;
|
||||
writeSettings();
|
||||
QFrame::showMinimized();
|
||||
}
|
||||
|
||||
bool MainFrame::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
const QEvent::Type type = event->type();
|
||||
@ -295,14 +330,6 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
|
||||
} else if (!_draging && type == QEvent::Leave) {
|
||||
_startPos = None;
|
||||
setCursor(Qt::ArrowCursor);
|
||||
} else if (type == QEvent::Resize) {
|
||||
if (isMaximized()) {
|
||||
hide_border();
|
||||
} else {
|
||||
show_border();
|
||||
}
|
||||
_titleBar->setRestoreButton(isMaximized());
|
||||
_layout->update();
|
||||
}
|
||||
|
||||
return QObject::eventFilter(object, event);
|
||||
@ -326,9 +353,16 @@ void MainFrame::readSettings()
|
||||
QRect deskRect = desktopWidget->availableGeometry();
|
||||
|
||||
settings.beginGroup("MainFrame");
|
||||
resize(settings.value("size", QSize(minWidth, minHeight)).toSize());
|
||||
move(settings.value("pos", QPoint((deskRect.width() - minWidth)/2, (deskRect.height() - minHeight)/2)).toPoint());
|
||||
QSize size = settings.value("size", QSize(minWidth, minHeight)).toSize();
|
||||
QPoint pos = settings.value("pos", QPoint((deskRect.width() - minWidth)/2, (deskRect.height() - minHeight)/2)).toPoint();
|
||||
settings.endGroup();
|
||||
|
||||
if (size == deskRect.size()) {
|
||||
_titleBar->showMaxRestore();
|
||||
} else {
|
||||
resize(size);
|
||||
move(pos);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pv
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
void showMaxRestore();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent* event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
@ -74,6 +76,7 @@ public slots:
|
||||
void unfreezing();
|
||||
void showNormal();
|
||||
void showMaximized();
|
||||
void showMinimized();
|
||||
|
||||
private:
|
||||
void hide_border();
|
||||
@ -103,6 +106,7 @@ private:
|
||||
int _startPos;
|
||||
QTimer _timer;
|
||||
bool _freezing;
|
||||
bool _minimized;
|
||||
};
|
||||
|
||||
} // namespace pv
|
||||
|
@ -199,8 +199,8 @@ void MainWindow::setup_ui()
|
||||
SLOT(show_calibration()));
|
||||
connect(_sampling_bar, SIGNAL(hide_calibration()), _view,
|
||||
SLOT(hide_calibration()));
|
||||
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(quint64)), _view,
|
||||
SLOT(set_trig_pos(quint64)));
|
||||
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view,
|
||||
SLOT(set_trig_pos(int)));
|
||||
connect(_protocol_widget, SIGNAL(protocol_updated()), _view, SLOT(signals_changed()));
|
||||
|
||||
setIconSize(QSize(40,40));
|
||||
@ -318,6 +318,7 @@ void MainWindow::update_device_list()
|
||||
}
|
||||
|
||||
if (!selected_device->name().contains("virtual")) {
|
||||
_file_bar->set_settings_en(true);
|
||||
_logo_bar->dsl_connected(true);
|
||||
QString ses_name = DS_RES_PATH +
|
||||
selected_device->name() +
|
||||
@ -325,9 +326,12 @@ void MainWindow::update_device_list()
|
||||
".dsc";
|
||||
load_session(ses_name);
|
||||
} else {
|
||||
_file_bar->set_settings_en(false);
|
||||
_logo_bar->dsl_connected(false);
|
||||
}
|
||||
_view->status_clear();
|
||||
_trigger_widget->init();
|
||||
_dso_trigger_widget->init();
|
||||
}
|
||||
|
||||
void MainWindow::reload()
|
||||
@ -416,7 +420,10 @@ void MainWindow::run_stop()
|
||||
switch(_session.get_capture_state()) {
|
||||
case SigSession::Init:
|
||||
case SigSession::Stopped:
|
||||
_view->show_trig_cursor(false);
|
||||
if (_session.get_device()->dev_inst()->mode == DSO)
|
||||
_view->show_trig_cursor(true);
|
||||
else
|
||||
_view->show_trig_cursor(false);
|
||||
_view->update_sample(false);
|
||||
commit_trigger(false);
|
||||
_session.start_capture(false,
|
||||
@ -436,7 +443,10 @@ void MainWindow::instant_stop()
|
||||
switch(_session.get_capture_state()) {
|
||||
case SigSession::Init:
|
||||
case SigSession::Stopped:
|
||||
_view->show_trig_cursor(false);
|
||||
if (_session.get_device()->dev_inst()->mode == DSO)
|
||||
_view->show_trig_cursor(true);
|
||||
else
|
||||
_view->show_trig_cursor(false);
|
||||
_view->update_sample(true);
|
||||
commit_trigger(true);
|
||||
_session.start_capture(true,
|
||||
@ -650,6 +660,8 @@ bool MainWindow::load_session(QString name)
|
||||
for (unsigned int i = 0; i < num_opts; i++) {
|
||||
const struct sr_config_info *const info =
|
||||
sr_config_info_get(options[i]);
|
||||
if (!sessionObj.contains(info->name))
|
||||
continue;
|
||||
if (info->datatype == SR_T_BOOL)
|
||||
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_boolean(sessionObj[info->name].toDouble()));
|
||||
else if (info->datatype == SR_T_UINT64)
|
||||
@ -709,8 +721,8 @@ bool MainWindow::load_session(QString name)
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
dsoSig->load_settings();
|
||||
dsoSig->set_zeroRate(obj["zeroPos"].toDouble());
|
||||
dsoSig->set_trigRate(obj["trigValue"].toDouble());
|
||||
dsoSig->set_zero_vrate(obj["zeroPos"].toDouble());
|
||||
dsoSig->set_trig_vrate(obj["trigValue"].toDouble());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -791,8 +803,8 @@ bool MainWindow::store_session(QString name)
|
||||
s_obj["vdiv"] = QJsonValue::fromVariant(static_cast<qulonglong>(dsoSig->get_vDialValue()));
|
||||
s_obj["vfactor"] = QJsonValue::fromVariant(static_cast<qulonglong>(dsoSig->get_factor()));
|
||||
s_obj["coupling"] = dsoSig->get_acCoupling();
|
||||
s_obj["trigValue"] = dsoSig->get_trigRate();
|
||||
s_obj["zeroPos"] = dsoSig->get_zeroRate();
|
||||
s_obj["trigValue"] = dsoSig->get_trig_vrate();
|
||||
s_obj["zeroPos"] = dsoSig->get_zero_vrate();
|
||||
}
|
||||
channelVar.append(s_obj);
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
|
||||
_group_cnt = 0;
|
||||
register_hotplug_callback();
|
||||
_view_timer.stop();
|
||||
_noData_cnt = 0;
|
||||
_refresh_timer.stop();
|
||||
_refresh_timer.setSingleShot(true);
|
||||
_data_lock = false;
|
||||
@ -470,12 +471,48 @@ double SigSession::cur_sampletime() const
|
||||
return _cur_samplelimits * 1.0 / _cur_samplerate;
|
||||
}
|
||||
|
||||
void SigSession::set_cur_samplerate(uint64_t samplerate)
|
||||
{
|
||||
assert(samplerate != 0);
|
||||
_cur_samplerate = samplerate;
|
||||
// sample rate for all SignalData
|
||||
// Logic/Analog/Dso
|
||||
if (_logic_data)
|
||||
_logic_data->set_samplerate(_cur_samplerate);
|
||||
if (_analog_data)
|
||||
_analog_data->set_samplerate(_cur_samplerate);
|
||||
if (_dso_data)
|
||||
_dso_data->set_samplerate(_cur_samplerate);
|
||||
// Group
|
||||
if (_group_data)
|
||||
_group_data->set_samplerate(_cur_samplerate);
|
||||
|
||||
#ifdef ENABLE_DECODE
|
||||
// DecoderStack
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::DecodeTrace> d, _decode_traces)
|
||||
d->decoder()->set_samplerate(_cur_samplerate);
|
||||
#endif
|
||||
// MathStack
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::MathTrace> m, _math_traces)
|
||||
m->get_math_stack()->set_samplerate(_cur_samplerate);
|
||||
}
|
||||
|
||||
void SigSession::set_cur_samplelimits(uint64_t samplelimits)
|
||||
{
|
||||
assert(samplelimits != 0);
|
||||
_cur_samplelimits = samplelimits;
|
||||
}
|
||||
|
||||
|
||||
void SigSession::capture_init()
|
||||
{
|
||||
_cur_samplerate = _dev_inst->get_sample_rate();
|
||||
_cur_samplelimits = _dev_inst->get_sample_limit();
|
||||
_data_updated = false;
|
||||
_view_timer.start(ViewTime);
|
||||
if (_dev_inst->dev_inst()->mode == DSO) {
|
||||
_view_timer.start(ViewTime);
|
||||
_noData_cnt = 0;
|
||||
}
|
||||
|
||||
// Init and Set sample rate for all SignalData
|
||||
// Logic/Analog/Dso
|
||||
@ -685,6 +722,10 @@ void SigSession::check_update()
|
||||
if (_data_updated) {
|
||||
data_updated();
|
||||
_data_updated = false;
|
||||
_noData_cnt = 0;
|
||||
} else {
|
||||
if (++_noData_cnt >= (WaitShowTime/ViewTime))
|
||||
show_wait_trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,13 @@ class SigSession : public QObject
|
||||
|
||||
private:
|
||||
static constexpr float Oversampling = 2.0f;
|
||||
static const int ViewTime = 50;
|
||||
static const int RefreshTime = 500;
|
||||
bool saveFileThreadRunning = false;
|
||||
|
||||
public:
|
||||
static const int ViewTime = 50;
|
||||
static const int WaitShowTime = 1000;
|
||||
|
||||
public:
|
||||
enum capture_state {
|
||||
Init,
|
||||
@ -131,6 +134,8 @@ public:
|
||||
uint64_t cur_samplerate() const;
|
||||
uint64_t cur_samplelimits() const;
|
||||
double cur_sampletime() const;
|
||||
void set_cur_samplerate(uint64_t samplerate);
|
||||
void set_cur_samplelimits(uint64_t samplelimits);
|
||||
QDateTime get_trigger_time() const;
|
||||
uint64_t get_trigger_pos() const;
|
||||
|
||||
@ -272,6 +277,7 @@ private:
|
||||
bool _hot_detach;
|
||||
|
||||
QTimer _view_timer;
|
||||
int _noData_cnt;
|
||||
QTimer _refresh_timer;
|
||||
bool _data_lock;
|
||||
bool _data_updated;
|
||||
@ -320,6 +326,8 @@ signals:
|
||||
|
||||
void hardware_connect_failed();
|
||||
|
||||
void show_wait_trigger();
|
||||
|
||||
public slots:
|
||||
void reload();
|
||||
void refresh(int holdtime);
|
||||
|
@ -69,7 +69,7 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
|
||||
_action_default->setObjectName(QString::fromUtf8("actionDefault"));
|
||||
connect(_action_default, SIGNAL(triggered()), this, SLOT(on_actionDefault_triggered()));
|
||||
|
||||
_menu_session = new QMenu(tr("Session"), parent);
|
||||
_menu_session = new QMenu(tr("Settings"), parent);
|
||||
_menu_session->setIcon(QIcon::fromTheme("file",
|
||||
QIcon(":/icons/gear.png")));
|
||||
_menu_session->setObjectName(QString::fromUtf8("menuSession"));
|
||||
@ -287,5 +287,10 @@ void FileBar::enable_toggle(bool enable)
|
||||
QIcon(":/icons/file_dis.png"));
|
||||
}
|
||||
|
||||
void FileBar::set_settings_en(bool enable)
|
||||
{
|
||||
_menu_session->setDisabled(!enable);
|
||||
}
|
||||
|
||||
} // namespace toolbars
|
||||
} // namespace pv
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
|
||||
void enable_toggle(bool enable);
|
||||
|
||||
void set_settings_en(bool enable);
|
||||
|
||||
private:
|
||||
|
||||
void session_error(
|
||||
|
@ -66,7 +66,7 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
|
||||
|
||||
connect(this, SIGNAL( normalShow() ), parent, SLOT(showNormal() ) );
|
||||
connect(this, SIGNAL( maximizedShow() ), parent, SLOT(showMaximized() ) );
|
||||
connect(_minimizeButton, SIGNAL( clicked() ), this, SLOT(showSmall() ) );
|
||||
connect(_minimizeButton, SIGNAL( clicked() ), parent, SLOT(showMinimized() ) );
|
||||
connect(_maximizeButton, SIGNAL( clicked() ), this, SLOT(showMaxRestore() ) );
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,6 @@ signals:
|
||||
void maximizedShow();
|
||||
|
||||
public slots:
|
||||
void showSmall() { parentWidget()->showMinimized(); }
|
||||
void showMaxRestore();
|
||||
void setRestoreButton(bool max);
|
||||
|
||||
|
@ -104,11 +104,6 @@ const QColor DsoSignal::SignalColours[4] = {
|
||||
};
|
||||
|
||||
const float DsoSignal::EnvelopeThreshold = 256.0f;
|
||||
const double DsoSignal::TrigMargin = 0.02;
|
||||
|
||||
const int DsoSignal::UpMargin = 30;
|
||||
const int DsoSignal::DownMargin = 0;
|
||||
const int DsoSignal::RightMargin = 30;
|
||||
|
||||
DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
boost::shared_ptr<data::Dso> data,
|
||||
@ -118,9 +113,6 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
_scale(0),
|
||||
_vDialActive(false),
|
||||
_hDialActive(false),
|
||||
//_trig_vpos(probe->index * 0.5 + 0.25),
|
||||
//_zeroPos(probe->index * 0.5 + 0.25)
|
||||
_trig_vpos(0.5),
|
||||
_autoV(false),
|
||||
_autoH(false),
|
||||
_hover_en(false),
|
||||
@ -176,7 +168,6 @@ boost::shared_ptr<pv::data::Dso> DsoSignal::dso_data() const
|
||||
void DsoSignal::set_viewport(pv::view::Viewport *viewport)
|
||||
{
|
||||
Trace::set_viewport(viewport);
|
||||
update_zeroPos();
|
||||
|
||||
const double ms_left = get_view_rect().right() - (MS_RectWidth + MS_RectMargin) * (get_index() + 1);
|
||||
const double ms_top = get_view_rect().top() + 5;
|
||||
@ -262,7 +253,7 @@ bool DsoSignal::go_vDialPre()
|
||||
g_variant_new_uint64(_vDial->get_value()));
|
||||
if (_view->session().get_capture_state() == SigSession::Stopped)
|
||||
_scale *= pre_vdiv/_vDial->get_value();
|
||||
update_zeroPos();
|
||||
update_offset();
|
||||
_view->update_calibration();
|
||||
_view->set_update(_viewport, true);
|
||||
_view->update();
|
||||
@ -282,7 +273,7 @@ bool DsoSignal::go_vDialNext()
|
||||
g_variant_new_uint64(_vDial->get_value()));
|
||||
if (_view->session().get_capture_state() == SigSession::Stopped)
|
||||
_scale *= pre_vdiv/_vDial->get_value();
|
||||
update_zeroPos();
|
||||
update_offset();
|
||||
_view->update_calibration();
|
||||
_view->set_update(_viewport, true);
|
||||
_view->update();
|
||||
@ -443,6 +434,15 @@ bool DsoSignal::load_settings()
|
||||
// qDebug() << "ERROR: config_get SR_CONF_EN_CH failed.";
|
||||
// return false;
|
||||
//}
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_DSO_BITS);
|
||||
if (gvar != NULL) {
|
||||
_bits = g_variant_get_byte(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
_bits = DefaultBits;
|
||||
qDebug("Warning: config_get SR_CONF_DSO_BITS failed, set to %d(default).", DefaultBits);
|
||||
return false;
|
||||
}
|
||||
|
||||
// -- hdiv
|
||||
uint64_t hdiv;
|
||||
@ -511,25 +511,19 @@ bool DsoSignal::load_settings()
|
||||
qDebug() << "ERROR: config_get SR_CONF_VPOS failed.";
|
||||
return false;
|
||||
}
|
||||
_zeroPos = min(max((0.5 - vpos / (_vDial->get_value() * DS_CONF_DSO_VDIVS)), 0.0), 1.0);
|
||||
_zero_off = _zeroPos * 255;
|
||||
_zero_vrate = min(max((0.5 - vpos / (_vDial->get_value() * DS_CONF_DSO_VDIVS)), 0.0), 1.0);
|
||||
_zero_value = _zero_vrate * ((1 << _bits) - 1);
|
||||
|
||||
// -- trig_value
|
||||
uint8_t trigger_value;
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TRIGGER_VALUE);
|
||||
if (gvar != NULL) {
|
||||
trigger_value = g_variant_get_byte(gvar);
|
||||
_trig_value = g_variant_get_byte(gvar);
|
||||
_trig_delta = get_trig_vrate() - _zero_vrate;
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TRIGGER_VALUE failed.";
|
||||
return false;
|
||||
}
|
||||
bool isDSCope = (_dev_inst->name() == "DSCope");
|
||||
if (isDSCope) {
|
||||
_trig_vpos = min(max(trigger_value/255.0, 0+TrigMargin), 1-TrigMargin);
|
||||
} else {
|
||||
_trig_vpos = min(max(_zeroPos + ((trigger_value - 0x80) / 255.0), 0+TrigMargin), 1-TrigMargin);
|
||||
}
|
||||
|
||||
if (_view) {
|
||||
_view->set_update(_viewport, true);
|
||||
@ -560,7 +554,7 @@ int DsoSignal::commit_settings()
|
||||
g_variant_new_byte(_acCoupling));
|
||||
|
||||
// -- vpos
|
||||
double vpos_off = (0.5 - (get_zeroPos() - UpMargin) * 1.0/get_view_rect().height()) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
|
||||
double vpos_off = (0.5 - (get_zero_vpos() - UpMargin) * 1.0/get_view_rect().height()) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
|
||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_VPOS,
|
||||
g_variant_new_double(vpos_off));
|
||||
|
||||
@ -603,88 +597,82 @@ void DsoSignal::set_acCoupling(uint8_t coupling)
|
||||
|
||||
int DsoSignal::get_trig_vpos() const
|
||||
{
|
||||
return _trig_vpos * get_view_rect().height() + UpMargin;
|
||||
return get_trig_vrate() * get_view_rect().height() + UpMargin;
|
||||
}
|
||||
|
||||
double DsoSignal::get_trigRate() const
|
||||
double DsoSignal::get_trig_vrate() const
|
||||
{
|
||||
return _trig_vpos;
|
||||
return _trig_value * 1.0 / ((1 << _bits) - 1.0);
|
||||
}
|
||||
|
||||
void DsoSignal::set_trig_vpos(int pos)
|
||||
void DsoSignal::set_trig_vpos(int pos, bool delta_change)
|
||||
{
|
||||
assert(_view);
|
||||
int trig_value;
|
||||
if (enabled()) {
|
||||
double delta = min((double)max(pos - UpMargin, 0), get_view_rect().height()) * 1.0 / get_view_rect().height();
|
||||
bool isDSCope = (_dev_inst->name() == "DSCope");
|
||||
if (isDSCope) {
|
||||
trig_value = delta * 255.0 + 0.5;
|
||||
_trig_vpos = min(max(trig_value/255.0, 0+TrigMargin), 1-TrigMargin);
|
||||
} else {
|
||||
delta = delta - _zeroPos;
|
||||
double delta = min(max(pos - UpMargin, 0), get_view_rect().height()) * 1.0 / get_view_rect().height();
|
||||
if (_dev_inst->name() == "DSLogic") {
|
||||
delta = delta - _zero_vrate;
|
||||
delta = min(delta, 0.5);
|
||||
delta = max(delta, -0.5);
|
||||
trig_value = (delta * 255.0f + 0x80);
|
||||
_trig_vpos = min(max(_zeroPos + (trig_value - 0x80) / 255.0, 0+TrigMargin), 1-TrigMargin);
|
||||
_trig_value = delta * ((1 << _bits) -1) + (1 << (_bits - 1));
|
||||
} else {
|
||||
_trig_value = delta * ((1 << _bits) -1) + 0.5;
|
||||
}
|
||||
int margin = TrigMargin;
|
||||
_trig_value = std::min(std::max(_trig_value, margin), ((1 << _bits) - margin - 1));
|
||||
if (delta_change)
|
||||
_trig_delta = get_trig_vrate() - _zero_vrate;
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
||||
g_variant_new_byte(trig_value));
|
||||
g_variant_new_byte(_trig_value));
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSignal::set_trigRate(double rate)
|
||||
void DsoSignal::set_trig_vrate(double rate)
|
||||
{
|
||||
int trig_value;
|
||||
double delta = rate;
|
||||
bool isDSCope = (_dev_inst->name() == "DSCope");
|
||||
if (isDSCope) {
|
||||
trig_value = delta * 255.0 + 0.5;
|
||||
_trig_vpos = min(max(trig_value/255.0, 0+TrigMargin), 1-TrigMargin);
|
||||
|
||||
} else {
|
||||
delta = delta - _zeroPos;
|
||||
if (_dev_inst->name() == "DSLogic") {
|
||||
delta = delta - _zero_vrate;
|
||||
delta = min(delta, 0.5);
|
||||
delta = max(delta, -0.5);
|
||||
trig_value = (delta * 255.0f + 0x80);
|
||||
_trig_vpos = min(max(_zeroPos + (trig_value - 0x80) / 255.0, 0+TrigMargin), 1-TrigMargin);
|
||||
_trig_value = delta * ((1 << _bits) - 1) + (1 << (_bits - 1));
|
||||
} else {
|
||||
_trig_value = delta * ((1 << _bits) - 1) + 0.5;
|
||||
}
|
||||
_trig_delta = get_trig_vrate() - _zero_vrate;
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
||||
g_variant_new_byte(trig_value));
|
||||
g_variant_new_byte(_trig_value));
|
||||
}
|
||||
|
||||
int DsoSignal::get_zeroPos()
|
||||
int DsoSignal::get_zero_vpos()
|
||||
{
|
||||
return _zeroPos * get_view_rect().height() + UpMargin;
|
||||
return _zero_vrate * get_view_rect().height() + UpMargin;
|
||||
}
|
||||
|
||||
double DsoSignal::get_zeroRate()
|
||||
double DsoSignal::get_zero_vrate()
|
||||
{
|
||||
return _zeroPos;
|
||||
return _zero_vrate;
|
||||
}
|
||||
|
||||
double DsoSignal::get_zeroValue()
|
||||
double DsoSignal::get_zero_value()
|
||||
{
|
||||
return _zero_off;
|
||||
return _zero_value;
|
||||
}
|
||||
|
||||
void DsoSignal::set_zeroPos(int pos)
|
||||
void DsoSignal::set_zero_vpos(int pos)
|
||||
{
|
||||
if (enabled()) {
|
||||
double delta = _trig_vpos - _zeroPos;
|
||||
set_trig_vpos(get_trig_vpos() + pos - get_zeroPos());
|
||||
_zeroPos = min((double)max(pos - UpMargin, 0), get_view_rect().height()) * 1.0 / get_view_rect().height();
|
||||
_trig_vpos = min(max(_zeroPos + delta, 0+TrigMargin), 1-TrigMargin);
|
||||
|
||||
update_zeroPos();
|
||||
double delta = _trig_delta* get_view_rect().height();
|
||||
_zero_vrate = min(max(pos - UpMargin, 0), get_view_rect().height()) * 1.0 / get_view_rect().height();
|
||||
set_trig_vpos(get_zero_vpos() + delta, false);
|
||||
update_offset();
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSignal::set_zeroRate(double rate)
|
||||
void DsoSignal::set_zero_vrate(double rate)
|
||||
{
|
||||
_zeroPos = rate;
|
||||
_zero_off = rate * 255;
|
||||
update_zeroPos();
|
||||
_zero_vrate = rate;
|
||||
_zero_value = rate * ((1 << _bits) - 1);
|
||||
update_offset();
|
||||
}
|
||||
|
||||
void DsoSignal::set_factor(uint64_t factor)
|
||||
@ -779,20 +767,17 @@ QString DsoSignal::get_ms_string(int index) const
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSignal::update_zeroPos()
|
||||
void DsoSignal::update_offset()
|
||||
{
|
||||
if (_dev_inst->name() == "DSCope") {
|
||||
//double vpos_off = (0.5 - _zeroPos) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
|
||||
double vpos_off = (0.5 - (get_zeroPos() - UpMargin) * 1.0/get_view_rect().height()) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_VPOS,
|
||||
g_variant_new_double(vpos_off));
|
||||
}
|
||||
double vpos_off = (0.5 - _zero_vrate) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_VPOS,
|
||||
g_variant_new_double(vpos_off));
|
||||
}
|
||||
|
||||
QRectF DsoSignal::get_view_rect() const
|
||||
QRect DsoSignal::get_view_rect() const
|
||||
{
|
||||
assert(_viewport);
|
||||
return QRectF(0, UpMargin,
|
||||
return QRect(0, UpMargin,
|
||||
_viewport->width() - RightMargin,
|
||||
_viewport->height() - UpMargin - DownMargin);
|
||||
}
|
||||
@ -871,7 +856,7 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
|
||||
const int height = get_view_rect().height();
|
||||
const int width = right - left;
|
||||
|
||||
const int y = get_zeroPos() + height * 0.5;
|
||||
const int y = get_zero_vpos() + height * 0.5;
|
||||
const double scale = _view->scale();
|
||||
assert(scale > 0);
|
||||
const double offset = _view->offset();
|
||||
@ -927,7 +912,7 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right)
|
||||
QPen pen(Signal::dsGray);
|
||||
pen.setStyle(Qt::DotLine);
|
||||
p.setPen(pen);
|
||||
p.drawLine(left, get_zeroPos(), right, get_zeroPos());
|
||||
p.drawLine(left, get_zero_vpos(), right, get_zero_vpos());
|
||||
|
||||
if(enabled()) {
|
||||
const QPointF mouse_point = _view->hover_point();
|
||||
@ -949,7 +934,7 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right)
|
||||
|
||||
// paint the trig voltage
|
||||
int trigp = get_trig_vpos();
|
||||
float t_vol = (_zeroPos - _trig_vpos) * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS;
|
||||
float t_vol = (_zero_vrate - get_trig_vrate()) * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS;
|
||||
QString t_vol_s = (_vDial->get_value() >= 500) ? QString::number(t_vol/1000.0f, 'f', 2)+"V" : QString::number(t_vol, 'f', 2)+"mV";
|
||||
int vol_width = p.boundingRect(0, 0, INT_MAX, INT_MAX,
|
||||
Qt::AlignLeft | Qt::AlignTop, t_vol_s).width();
|
||||
@ -998,10 +983,10 @@ void DsoSignal::paint_trace(QPainter &p,
|
||||
|
||||
float top = get_view_rect().top();
|
||||
float bottom = get_view_rect().bottom();
|
||||
float zeroP = _zeroPos * get_view_rect().height() + top;;
|
||||
float zeroP = _zero_vrate * get_view_rect().height() + top;;
|
||||
if (_dev_inst->name() == "DSCope" &&
|
||||
_view->session().get_capture_state() == SigSession::Running)
|
||||
_zero_off = _zeroPos * 255;
|
||||
_zero_value = _zero_vrate * ((1 << _bits) - 1);
|
||||
float x = (start / samples_per_pixel - pixels_offset) + left;
|
||||
double pixels_per_sample = 1.0/samples_per_pixel;
|
||||
uint8_t offset;
|
||||
@ -1012,7 +997,7 @@ void DsoSignal::paint_trace(QPainter &p,
|
||||
|
||||
//offset = samples[(sample - start)*num_channels];
|
||||
offset = samples[sample];
|
||||
const float y = min(max(top, zeroP + (offset - _zero_off) * _scale), bottom);
|
||||
const float y = min(max(top, zeroP + (offset - _zero_value) * _scale), bottom);
|
||||
*point++ = QPointF(x, y);
|
||||
x += pixels_per_sample;
|
||||
//*point++ = QPointF(x, top + offset);
|
||||
@ -1054,10 +1039,10 @@ void DsoSignal::paint_envelope(QPainter &p,
|
||||
QRectF *rect = rects;
|
||||
float top = get_view_rect().top();
|
||||
float bottom = get_view_rect().bottom();
|
||||
float zeroP = _zeroPos * get_view_rect().height() + top;
|
||||
float zeroP = _zero_vrate * get_view_rect().height() + top;
|
||||
if (_dev_inst->name() == "DSCope" &&
|
||||
_view->session().get_capture_state() == SigSession::Running)
|
||||
_zero_off = _zeroPos * 255;
|
||||
_zero_value = _zero_vrate * ((1 << _bits) - 1);
|
||||
for(uint64_t sample = 0; sample < e.length-1; sample++) {
|
||||
const float x = ((e.scale * sample + e.start) /
|
||||
samples_per_pixel - pixels_offset) + left;
|
||||
@ -1066,8 +1051,8 @@ void DsoSignal::paint_envelope(QPainter &p,
|
||||
|
||||
// We overlap this sample with the next so that vertical
|
||||
// gaps do not appear during steep rising or falling edges
|
||||
const float b = min(max(top, ((max(s->max, (s+1)->min) - _zero_off) * _scale + zeroP)), bottom);
|
||||
const float t = min(max(top, ((min(s->min, (s+1)->max) - _zero_off) * _scale + zeroP)), bottom);
|
||||
const float b = min(max(top, ((max(s->max, (s+1)->min) - _zero_value) * _scale + zeroP)), bottom);
|
||||
const float t = min(max(top, ((min(s->min, (s+1)->max) - _zero_value) * _scale + zeroP)), bottom);
|
||||
|
||||
float h = b - t;
|
||||
if(h >= 0.0f && h <= 1.0f)
|
||||
@ -1131,23 +1116,23 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
return;
|
||||
}
|
||||
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush((enabled() && (factor == 100)) ? (x100_rect.contains(pt) ? _colour.darker() : _colour) : (x100_rect.contains(pt) ? _colour.darker() : dsDisable));
|
||||
p.drawRect(x100_rect);
|
||||
p.drawText(x100_rect, Qt::AlignCenter | Qt::AlignVCenter, "x100");
|
||||
|
||||
p.setBrush((enabled() && (factor == 10)) ? (x10_rect.contains(pt) ? _colour.darker() : _colour) : (x10_rect.contains(pt) ? _colour.darker() : dsDisable));
|
||||
p.drawRect(x10_rect);
|
||||
p.drawText(x10_rect, Qt::AlignCenter | Qt::AlignVCenter, "x10");
|
||||
|
||||
p.setBrush((enabled() && (factor == 1)) ? (x1_rect.contains(pt) ? _colour.darker() : _colour) : (x1_rect.contains(pt) ? _colour.darker() : dsDisable));
|
||||
p.drawRect(x1_rect);
|
||||
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(x100_rect, Qt::AlignCenter | Qt::AlignVCenter, "x100");
|
||||
p.drawText(x10_rect, Qt::AlignCenter | Qt::AlignVCenter, "x10");
|
||||
p.drawText(x1_rect, Qt::AlignCenter | Qt::AlignVCenter, "x1");
|
||||
}
|
||||
|
||||
bool DsoSignal::mouse_double_click(int right, const QPoint pt)
|
||||
{
|
||||
int y = get_zeroPos();
|
||||
int y = get_zero_vpos();
|
||||
const QRectF label_rect = Trace::get_rect("label", y, right);
|
||||
if (label_rect.contains(pt)) {
|
||||
this->auto_set();
|
||||
@ -1326,8 +1311,8 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
_min = (index == 0) ? status.ch0_min : status.ch1_min;
|
||||
const uint64_t period = (index == 0) ? status.ch0_period : status.ch1_period;
|
||||
const uint32_t count = (index == 0) ? status.ch0_pcnt : status.ch1_pcnt;
|
||||
double value_max = (_zero_off - _min) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
double value_min = (_zero_off - _max) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
double value_max = (_zero_value - _min) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
double value_min = (_zero_value - _max) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
double value_p2p = value_max - value_min;
|
||||
_period = (count == 0) ? period * 10.0 : period * 10.0 / count;
|
||||
const int channel_count = _view->session().get_ch_num(SR_CHANNEL_DSO);
|
||||
@ -1348,7 +1333,7 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
if (!snapshots.empty()) {
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
const double vrms = snapshot->cal_vrms(_zero_off, get_index());
|
||||
const double vrms = snapshot->cal_vrms(_zero_value, get_index());
|
||||
const double value_vrms = vrms * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
_ms_string[DSO_MS_VRMS] = "Vrms: " + (abs(value_vrms) > 1000 ? QString::number(value_vrms/1000.0, 'f', 2) + "V" : QString::number(value_vrms, 'f', 2) + "mV");
|
||||
}
|
||||
@ -1361,7 +1346,7 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
const double vmean = snapshot->cal_vmean(get_index());
|
||||
const double value_vmean = (_zero_off - vmean) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
const double value_vmean = (_zero_value - vmean) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
_ms_string[DSO_MS_VMEA] = "Vmean: " + (abs(value_vmean) > 1000 ? QString::number(value_vmean/1000.0, 'f', 2) + "V" : QString::number(value_vmean, 'f', 2) + "mV");
|
||||
}
|
||||
}
|
||||
@ -1527,17 +1512,17 @@ bool DsoSignal::measure(const QPointF &p)
|
||||
const uint8_t cur_sample = *snapshot->get_samples(_hover_index, _hover_index, get_index());
|
||||
const uint8_t nxt_sample = *snapshot->get_samples(nxt_index, nxt_index, get_index());
|
||||
|
||||
_hover_value = (_zero_off - cur_sample) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
_hover_value = (_zero_value - cur_sample) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
|
||||
float top = get_view_rect().top();
|
||||
float bottom = get_view_rect().bottom();
|
||||
float zeroP = _zeroPos * get_view_rect().height() + top;
|
||||
float zeroP = _zero_vrate * get_view_rect().height() + top;
|
||||
float pre_x = (pre_index / samples_per_pixel - pixels_offset);
|
||||
const float pre_y = min(max(top, zeroP + (pre_sample - _zero_off)* _scale), bottom);
|
||||
const float pre_y = min(max(top, zeroP + (pre_sample - _zero_value)* _scale), bottom);
|
||||
float x = (_hover_index / samples_per_pixel - pixels_offset);
|
||||
const float y = min(max(top, zeroP + (cur_sample - _zero_off)* _scale), bottom);
|
||||
const float y = min(max(top, zeroP + (cur_sample - _zero_value)* _scale), bottom);
|
||||
float nxt_x = (nxt_index / samples_per_pixel - pixels_offset);
|
||||
const float nxt_y = min(max(top, zeroP + (nxt_sample - _zero_off)* _scale), bottom);
|
||||
const float nxt_y = min(max(top, zeroP + (nxt_sample - _zero_value)* _scale), bottom);
|
||||
const QRectF slope_rect = QRectF(QPointF(pre_x - 10, pre_y - 10), QPointF(nxt_x + 10, nxt_y + 10));
|
||||
if (abs(y-p.y()) < 20 || slope_rect.contains(p)) {
|
||||
_hover_point = QPointF(x, y);
|
||||
|
@ -43,7 +43,6 @@ class DsoSignal : public Signal
|
||||
private:
|
||||
static const QColor SignalColours[4];
|
||||
static const float EnvelopeThreshold;
|
||||
static const double TrigMargin;
|
||||
|
||||
static const int HitCursorMargin = 3;
|
||||
static const uint64_t vDialValueCount = 8;
|
||||
@ -58,9 +57,12 @@ private:
|
||||
static const uint64_t hDialValue[hDialValueCount];
|
||||
static const QString hDialUnit[hDialUnitCount];
|
||||
|
||||
static const int UpMargin;
|
||||
static const int DownMargin;
|
||||
static const int RightMargin;
|
||||
static const int UpMargin = 30;
|
||||
static const int DownMargin = 0;
|
||||
static const int RightMargin = 30;
|
||||
|
||||
static const uint8_t DefaultBits = 8;
|
||||
static const int TrigMargin = 16;
|
||||
|
||||
public:
|
||||
enum DSO_MEASURE_TYPE {
|
||||
@ -130,10 +132,10 @@ public:
|
||||
uint16_t get_hDialSel() const;
|
||||
uint8_t get_acCoupling() const;
|
||||
void set_acCoupling(uint8_t coupling);
|
||||
void set_trig_vpos(int pos);
|
||||
void set_trig_vpos(int pos, bool delta_change);
|
||||
int get_trig_vpos() const;
|
||||
void set_trigRate(double rate);
|
||||
double get_trigRate() const;
|
||||
void set_trig_vrate(double rate);
|
||||
double get_trig_vrate() const;
|
||||
void set_factor(uint64_t factor);
|
||||
uint64_t get_factor();
|
||||
|
||||
@ -154,15 +156,15 @@ public:
|
||||
/**
|
||||
* Gets the mid-Y position of this signal.
|
||||
*/
|
||||
int get_zeroPos();
|
||||
double get_zeroRate();
|
||||
double get_zeroValue();
|
||||
int get_zero_vpos();
|
||||
double get_zero_vrate();
|
||||
double get_zero_value();
|
||||
/**
|
||||
* Sets the mid-Y position of this signal.
|
||||
*/
|
||||
void set_zeroPos(int pos);
|
||||
void set_zeroRate(double rate);
|
||||
void update_zeroPos();
|
||||
void set_zero_vpos(int pos);
|
||||
void set_zero_vrate(double rate);
|
||||
void update_offset();
|
||||
|
||||
/**
|
||||
* Paints the background layer of the trace with a QPainter
|
||||
@ -190,7 +192,7 @@ public:
|
||||
|
||||
const std::vector< std::pair<uint64_t, bool> > cur_edges() const;
|
||||
|
||||
QRectF get_view_rect() const;
|
||||
QRect get_view_rect() const;
|
||||
|
||||
QRectF get_trig_rect(int left, int right) const;
|
||||
|
||||
@ -237,10 +239,12 @@ private:
|
||||
bool _vDialActive;
|
||||
bool _hDialActive;
|
||||
uint8_t _acCoupling;
|
||||
uint8_t _bits;
|
||||
|
||||
double _trig_vpos;
|
||||
double _zeroPos;
|
||||
float _zero_off;
|
||||
int _trig_value;
|
||||
double _trig_delta;
|
||||
double _zero_vrate;
|
||||
float _zero_value;
|
||||
|
||||
uint8_t _max;
|
||||
uint8_t _min;
|
||||
|
@ -198,7 +198,7 @@ void Header::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
// Add the Trace to the drag list
|
||||
if (event->button() & Qt::LeftButton) {
|
||||
_drag_traces.push_back(make_pair(mTrace, mTrace->get_zeroPos()));
|
||||
_drag_traces.push_back(make_pair(mTrace, mTrace->get_zero_vpos()));
|
||||
}
|
||||
}
|
||||
mTrace->set_old_v_offset(mTrace->get_v_offset());
|
||||
@ -315,7 +315,7 @@ void Header::mouseMoveEvent(QMouseEvent *event)
|
||||
} else {
|
||||
boost::shared_ptr<DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<DsoSignal>(sig)) {
|
||||
dsoSig->set_zeroPos(y);
|
||||
dsoSig->set_zero_vpos(y);
|
||||
dsoSig->select(false);
|
||||
traces_moved();
|
||||
}
|
||||
|
@ -217,13 +217,13 @@ QString MathTrace::format_freq(double freq, unsigned precision)
|
||||
}
|
||||
}
|
||||
|
||||
bool MathTrace::measure(const QPointF &p)
|
||||
bool MathTrace::measure(const QPoint &p)
|
||||
{
|
||||
_hover_en = false;
|
||||
if(!_view || !enabled())
|
||||
return false;
|
||||
|
||||
const QRectF window = get_view_rect();
|
||||
const QRect window = get_view_rect();
|
||||
if (!window.contains(p))
|
||||
return false;
|
||||
|
||||
@ -291,14 +291,12 @@ void MathTrace::paint_mid(QPainter &p, int left, int right)
|
||||
|
||||
double vdiv;
|
||||
double vfactor;
|
||||
double voffset;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, _session.get_signals()) {
|
||||
boost::shared_ptr<DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<DsoSignal>(s)) {
|
||||
if(dsoSig->get_index() == _math_stack->get_index()) {
|
||||
vdiv = dsoSig->get_vDialValue();
|
||||
vfactor = dsoSig->get_factor();
|
||||
voffset = dsoSig->get_zeroRate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -476,10 +474,10 @@ void MathTrace::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
(void)right;
|
||||
}
|
||||
|
||||
QRectF MathTrace::get_view_rect() const
|
||||
QRect MathTrace::get_view_rect() const
|
||||
{
|
||||
assert(_viewport);
|
||||
return QRectF(0, UpMargin,
|
||||
return QRect(0, UpMargin,
|
||||
_viewport->width() - RightMargin,
|
||||
_viewport->height() - UpMargin - DownMargin);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
|
||||
static QString format_freq(double freq, unsigned precision = Pricision);
|
||||
|
||||
bool measure(const QPointF &p);
|
||||
bool measure(const QPoint &p);
|
||||
|
||||
/**
|
||||
* Paints the background layer of the trace with a QPainter
|
||||
@ -121,7 +121,7 @@ public:
|
||||
**/
|
||||
void paint_fore(QPainter &p, int left, int right);
|
||||
|
||||
QRectF get_view_rect() const;
|
||||
QRect get_view_rect() const;
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt);
|
||||
|
@ -70,8 +70,10 @@ void TimeMarker::set_index(uint64_t index)
|
||||
|
||||
void TimeMarker::paint(QPainter &p, const QRect &rect, const bool highlight)
|
||||
{
|
||||
const double samples_per_pixel = _view.session().cur_samplerate() * _view.scale();
|
||||
const double x = _index/samples_per_pixel - (_view.offset() / _view.scale());
|
||||
const uint64_t sample_rate = _view.session().cur_samplerate();
|
||||
const double scale = _view.scale();
|
||||
const double samples_per_pixel = sample_rate * scale;
|
||||
const double x = _index/samples_per_pixel - (_view.offset() / scale);
|
||||
p.setPen((_grabbed | highlight) ? QPen(_colour.lighter(), 2, Qt::DashLine) : QPen(_colour, 1, Qt::DashLine));
|
||||
p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom()));
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ void Trace::set_old_v_offset(int v_offset)
|
||||
_old_v_offset = v_offset;
|
||||
}
|
||||
|
||||
int Trace::get_zeroPos()
|
||||
int Trace::get_zero_vpos()
|
||||
{
|
||||
return _v_offset;
|
||||
}
|
||||
@ -256,7 +256,7 @@ void Trace::paint_label(QPainter &p, int right, const QPoint pt)
|
||||
|
||||
const QRectF color_rect = get_rect("color", y, right);
|
||||
const QRectF name_rect = get_rect("name", y, right);
|
||||
const QRectF label_rect = get_rect("label", get_zeroPos(), right);
|
||||
const QRectF label_rect = get_rect("label", get_zero_vpos(), right);
|
||||
|
||||
//p.setRenderHint(QPainter::Antialiasing);
|
||||
// Paint the ColorButton
|
||||
@ -276,7 +276,7 @@ void Trace::paint_label(QPainter &p, int right, const QPoint pt)
|
||||
const QPointF points[] = {
|
||||
label_rect.topLeft(),
|
||||
label_rect.topRight(),
|
||||
QPointF(right, get_zeroPos()),
|
||||
QPointF(right, get_zero_vpos()),
|
||||
label_rect.bottomRight(),
|
||||
label_rect.bottomLeft()
|
||||
};
|
||||
@ -339,7 +339,7 @@ int Trace::pt_in_rect(int y, int right, const QPoint &point)
|
||||
{
|
||||
const QRectF color = get_rect("color", y, right);
|
||||
const QRectF name = get_rect("name", y, right);
|
||||
const QRectF label = get_rect("label", get_zeroPos(), right);
|
||||
const QRectF label = get_rect("label", get_zero_vpos(), right);
|
||||
|
||||
if (color.contains(point) && enabled())
|
||||
return COLOR;
|
||||
@ -364,10 +364,10 @@ void Trace::compute_text_size(QPainter &p)
|
||||
p.boundingRect(QRectF(), 0, "99").height());
|
||||
}
|
||||
|
||||
QRectF Trace::get_view_rect() const
|
||||
QRect Trace::get_view_rect() const
|
||||
{
|
||||
assert(_view);
|
||||
return QRectF(0, 0, _view->viewport()->width(), _view->viewport()->height());
|
||||
return QRect(0, 0, _view->viewport()->width(), _view->viewport()->height());
|
||||
}
|
||||
|
||||
int Trace::get_y() const
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
*/
|
||||
void set_old_v_offset(int v_offset);
|
||||
|
||||
virtual int get_zeroPos();
|
||||
virtual int get_zero_vpos();
|
||||
|
||||
/**
|
||||
* Returns true if the trace is visible and enabled.
|
||||
@ -241,7 +241,7 @@ public:
|
||||
|
||||
virtual int rows_size();
|
||||
|
||||
virtual QRectF get_view_rect() const;
|
||||
virtual QRect get_view_rect() const;
|
||||
|
||||
virtual bool mouse_double_click(int right, const QPoint pt);
|
||||
|
||||
|
@ -155,13 +155,15 @@ View::View(SigSession &session, pv::toolbars::SamplingBar *sampling_bar, QWidget
|
||||
connect(&_session, SIGNAL(receive_header()),
|
||||
this, SLOT(receive_header()));
|
||||
connect(&_session, SIGNAL(receive_trigger(quint64)),
|
||||
this, SLOT(set_trig_pos(quint64)));
|
||||
this, SLOT(receive_trigger(quint64)));
|
||||
connect(&_session, SIGNAL(frame_ended()),
|
||||
this, SLOT(receive_end()));
|
||||
connect(&_session, SIGNAL(frame_began()),
|
||||
this, SLOT(frame_began()));
|
||||
connect(&_session, SIGNAL(show_region(uint64_t,uint64_t)),
|
||||
this, SLOT(show_region(uint64_t, uint64_t)));
|
||||
connect(&_session, SIGNAL(show_wait_trigger()),
|
||||
_time_viewport, SLOT(show_wait_trigger()));
|
||||
|
||||
// connect(_devmode, SIGNAL(mode_changed()),
|
||||
// this, SIGNAL(mode_changed()));
|
||||
@ -248,14 +250,20 @@ void View::update_sample(bool instant)
|
||||
|
||||
void View::set_sample_rate(uint64_t sample_rate, bool force)
|
||||
{
|
||||
if (_session.get_capture_state() != pv::SigSession::Stopped || force)
|
||||
if (_session.get_capture_state() != pv::SigSession::Stopped || force) {
|
||||
_sampling_bar->set_sample_rate(sample_rate);
|
||||
_session.set_cur_samplerate(_session.get_device()->get_sample_rate());
|
||||
}
|
||||
}
|
||||
|
||||
void View::set_sample_limit(uint64_t sample_limit, bool force)
|
||||
{
|
||||
if (_session.get_capture_state() != pv::SigSession::Stopped || force)
|
||||
if (_session.get_capture_state() != pv::SigSession::Stopped || force) {
|
||||
_sampling_bar->set_sample_limit(sample_limit);
|
||||
const uint64_t final_limit = _session.get_device()->get_sample_limit();
|
||||
_trig_cursor->set_index(_trig_cursor->index() * 1.0 / _session.cur_samplelimits() * final_limit);
|
||||
_session.set_cur_samplelimits(final_limit);
|
||||
}
|
||||
}
|
||||
|
||||
void View::zoom(double steps, int offset)
|
||||
@ -442,13 +450,16 @@ void View::receive_end()
|
||||
}
|
||||
}
|
||||
}
|
||||
_time_viewport->unshow_wait_trigger();
|
||||
}
|
||||
|
||||
void View::set_trig_pos(quint64 trig_pos)
|
||||
void View::receive_trigger(quint64 trig_pos)
|
||||
{
|
||||
const double time = trig_pos * 1.0 / _session.cur_samplerate();
|
||||
_trig_cursor->set_index(trig_pos);
|
||||
if (ds_trigger_get_en() || _session.get_device()->name() == "virtual-session") {
|
||||
if (ds_trigger_get_en() ||
|
||||
_session.get_device()->name() == "virtual-session" ||
|
||||
_session.get_device()->dev_inst()->mode == DSO) {
|
||||
_show_trig_cursor = true;
|
||||
set_scale_offset(_scale, time - _scale * get_view_width() / 2);
|
||||
}
|
||||
@ -457,6 +468,12 @@ void View::set_trig_pos(quint64 trig_pos)
|
||||
viewport_update();
|
||||
}
|
||||
|
||||
void View::set_trig_pos(int percent)
|
||||
{
|
||||
uint64_t index = _session.cur_samplelimits() * percent / 100;
|
||||
receive_trigger(index);
|
||||
}
|
||||
|
||||
void View::set_search_pos(uint64_t search_pos)
|
||||
{
|
||||
//assert(search_pos >= 0);
|
||||
@ -474,7 +491,7 @@ uint64_t View::get_search_pos()
|
||||
return _search_pos;
|
||||
}
|
||||
|
||||
const QPointF& View::hover_point() const
|
||||
const QPoint& View::hover_point() const
|
||||
{
|
||||
return _hover_point;
|
||||
}
|
||||
@ -567,7 +584,7 @@ void View::update_scale_offset()
|
||||
_preScale = _scale;
|
||||
_preOffset = _offset;
|
||||
|
||||
_trig_cursor->set_index(_session.get_trigger_pos());
|
||||
//_trig_cursor->set_index(_session.get_trigger_pos());
|
||||
|
||||
_ruler->update();
|
||||
viewport_update();
|
||||
@ -676,10 +693,10 @@ bool View::eventFilter(QObject *object, QEvent *event)
|
||||
if (object == _ruler || object == _time_viewport || object == _fft_viewport) {
|
||||
//_hover_point = QPoint(mouse_event->x(), 0);
|
||||
double cur_periods = (mouse_event->pos().x() * _scale + _offset) / _ruler->get_min_period();
|
||||
double integer_x = (round(cur_periods) * _ruler->get_min_period() - _offset ) / _scale;
|
||||
int integer_x = (round(cur_periods) * _ruler->get_min_period() - _offset ) / _scale;
|
||||
double cur_deviate_x = qAbs(mouse_event->pos().x() - integer_x);
|
||||
if (cur_deviate_x < 10)
|
||||
_hover_point = QPointF(integer_x, mouse_event->pos().y());
|
||||
_hover_point = QPoint(integer_x, mouse_event->pos().y());
|
||||
else
|
||||
_hover_point = mouse_event->pos();
|
||||
} else if (object == _header)
|
||||
@ -799,6 +816,7 @@ void View::data_updated()
|
||||
update_scroll();
|
||||
|
||||
// Repaint the view
|
||||
_time_viewport->unshow_wait_trigger();
|
||||
set_update(_time_viewport, true);
|
||||
set_update(_fft_viewport, true);
|
||||
viewport_update();
|
||||
@ -953,13 +971,25 @@ void View::on_state_changed(bool stop)
|
||||
update_scale_offset();
|
||||
}
|
||||
|
||||
QRect View::get_view_rect()
|
||||
{
|
||||
if (_session.get_device()->dev_inst()->mode == DSO) {
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
return s->get_view_rect();
|
||||
}
|
||||
} else {
|
||||
return _viewcenter->rect();
|
||||
}
|
||||
}
|
||||
|
||||
int View::get_view_width()
|
||||
{
|
||||
int view_width = 0;
|
||||
if (_session.get_device()->dev_inst()->mode == DSO) {
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
view_width = max((double)view_width, s->get_view_rect().width());
|
||||
view_width = max(view_width, s->get_view_rect().width());
|
||||
}
|
||||
} else {
|
||||
view_width = _viewcenter->width();
|
||||
@ -974,7 +1004,7 @@ int View::get_view_height()
|
||||
if (_session.get_device()->dev_inst()->mode == DSO) {
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
view_height = max((double)view_height, s->get_view_rect().height());
|
||||
view_height = max(view_height, s->get_view_rect().height());
|
||||
}
|
||||
} else {
|
||||
view_height = _viewcenter->height();
|
||||
|
@ -139,7 +139,7 @@ public:
|
||||
*/
|
||||
void show_cursors(bool show = true);
|
||||
|
||||
const QPointF& hover_point() const;
|
||||
const QPoint& hover_point() const;
|
||||
|
||||
void normalize_layout();
|
||||
|
||||
@ -158,7 +158,6 @@ public:
|
||||
Cursor* get_trig_cursor();
|
||||
Cursor* get_search_cursor();
|
||||
|
||||
//void set_trig_pos(uint64_t trig_pos);
|
||||
void set_search_pos(uint64_t search_pos);
|
||||
|
||||
uint64_t get_search_pos();
|
||||
@ -180,6 +179,7 @@ public:
|
||||
|
||||
void on_state_changed(bool stop);
|
||||
|
||||
QRect get_view_rect();
|
||||
int get_view_width();
|
||||
int get_view_height();
|
||||
|
||||
@ -248,7 +248,8 @@ private slots:
|
||||
|
||||
void receive_header();
|
||||
|
||||
void set_trig_pos(quint64 trig_pos);
|
||||
void receive_trigger(quint64 trig_pos);
|
||||
void set_trig_pos(int percent);
|
||||
|
||||
void receive_end();
|
||||
|
||||
@ -302,7 +303,7 @@ private:
|
||||
bool _show_search_cursor;
|
||||
uint64_t _search_pos;
|
||||
|
||||
QPointF _hover_point;
|
||||
QPoint _hover_point;
|
||||
dialogs::Calibration *_cali;
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,8 @@ Viewport::Viewport(View &parent, View_type type) :
|
||||
_hover_index(0),
|
||||
_hover_hit(false),
|
||||
_dso_xm_valid(false),
|
||||
_dso_ym_valid(false)
|
||||
_dso_ym_valid(false),
|
||||
_waiting_trig(0)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setAutoFillBackground(true);
|
||||
@ -236,6 +237,16 @@ void Viewport::paintSignals(QPainter &p)
|
||||
|
||||
//plot measure arrow
|
||||
paintMeasure(p);
|
||||
|
||||
//plot waiting trigger
|
||||
if (_waiting_trig > 0) {
|
||||
p.setPen(Trace::DARK_FORE);
|
||||
QString text = "Waiting Trig";
|
||||
for (int i = 1; i < _waiting_trig; i++)
|
||||
if (i % (WaitLoopTime / SigSession::ViewTime) == 0)
|
||||
text += ".";
|
||||
p.drawText(_view.get_view_rect(), Qt::AlignLeft | Qt::AlignTop, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,7 +457,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
if (_drag_sig) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(_drag_sig))
|
||||
dsoSig->set_trig_vpos(event->pos().y());
|
||||
dsoSig->set_trig_vpos(event->pos().y(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +465,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
uint64_t sample_rate = _view.session().cur_samplerate();
|
||||
TimeMarker* grabbed_marker = _view.get_ruler()->get_grabbed_cursor();
|
||||
if (_view.cursors_shown() && grabbed_marker) {
|
||||
double curX = _view.hover_point().x();
|
||||
int curX = _view.hover_point().x();
|
||||
uint64_t index0 = 0, index1 = 0, index2 = 0;
|
||||
bool logic = false;
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_view.session().get_signals());
|
||||
@ -1279,6 +1290,19 @@ void Viewport::set_need_update(bool update)
|
||||
_need_update = update;
|
||||
}
|
||||
|
||||
void Viewport::show_wait_trigger()
|
||||
{
|
||||
_waiting_trig %= (WaitLoopTime / SigSession::ViewTime) * 4;
|
||||
_waiting_trig++;
|
||||
update();
|
||||
}
|
||||
|
||||
void Viewport::unshow_wait_trigger()
|
||||
{
|
||||
_waiting_trig = 0;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
static const double MinorDragRateUp;
|
||||
static const double DragDamping;
|
||||
static const int SnapMinSpace = 10;
|
||||
static const int WaitLoopTime = 400;
|
||||
enum ActionType {
|
||||
NO_ACTION,
|
||||
|
||||
@ -123,6 +124,10 @@ private slots:
|
||||
void on_drag_timer();
|
||||
void set_receive_len(quint64 length);
|
||||
|
||||
public slots:
|
||||
void show_wait_trigger();
|
||||
void unshow_wait_trigger();
|
||||
|
||||
signals:
|
||||
void measure_updated();
|
||||
|
||||
@ -188,6 +193,8 @@ private:
|
||||
uint64_t _dso_ym_index;
|
||||
int _dso_ym_start;
|
||||
int _dso_ym_end;
|
||||
|
||||
int _waiting_trig;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
@ -91,6 +91,7 @@ static const int32_t sessions[] = {
|
||||
SR_CONF_TRIGGER_SOURCE,
|
||||
SR_CONF_HORIZ_TRIGGERPOS,
|
||||
SR_CONF_TRIGGER_HOLDOFF,
|
||||
SR_CONF_TRIGGER_MARGIN,
|
||||
};
|
||||
|
||||
static const char *probe_names[] = {
|
||||
@ -392,7 +393,7 @@ static int fpga_config(struct libusb_device_handle *hdl, const char *filename)
|
||||
struct stat f_stat;
|
||||
|
||||
sr_info("Configure FPGA using %s", filename);
|
||||
if ((fw = g_fopen(filename, "rb")) == NULL) {
|
||||
if ((fw = fopen(filename, "rb")) == NULL) {
|
||||
sr_err("Unable to open FPGA bit file %s for reading: %s",
|
||||
filename, strerror(errno));
|
||||
return SR_ERR;
|
||||
@ -636,6 +637,8 @@ static struct DSL_context *DSCope_dev_new(void)
|
||||
devc->zero = FALSE;
|
||||
devc->data_lock = FALSE;
|
||||
devc->cali = FALSE;
|
||||
devc->dso_bits = 8;
|
||||
devc->trigger_margin = 0;
|
||||
|
||||
return devc;
|
||||
}
|
||||
@ -1023,6 +1026,10 @@ static uint64_t dso_cmd_gen(struct sr_dev_inst *sdi, struct sr_channel* ch, int
|
||||
cmd += probe->trig_value << (8 * (probe->index + 1));
|
||||
}
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MARGIN:
|
||||
cmd += 0x40;
|
||||
cmd += ((uint64_t)devc->trigger_margin << 8);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_HOLDOFF:
|
||||
cmd += 0x58;
|
||||
cmd += ((uint64_t)devc->trigger_holdoff << 8);
|
||||
@ -1237,6 +1244,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_uint64(devc->trigger_holdoff);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MARGIN:
|
||||
if (!sdi)
|
||||
return SR_ERR;
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_byte(devc->trigger_margin);
|
||||
break;
|
||||
case SR_CONF_ZERO:
|
||||
if (!sdi)
|
||||
return SR_ERR;
|
||||
@ -1335,6 +1348,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
return SR_ERR;
|
||||
*data = g_variant_new_uint16(CALI_VOFF_RANGE);
|
||||
break;
|
||||
case SR_CONF_DSO_BITS:
|
||||
if (!sdi)
|
||||
return SR_ERR;
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_byte(devc->dso_bits);
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
@ -1600,6 +1619,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
else
|
||||
sr_dbg("%s: setting Trigger Holdoff Time to %d failed",
|
||||
__func__, devc->trigger_holdoff);
|
||||
} else if (id == SR_CONF_TRIGGER_MARGIN) {
|
||||
devc->trigger_margin = g_variant_get_byte(data);
|
||||
if (sdi->mode == DSO) {
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_MARGIN));
|
||||
}
|
||||
if (ret == SR_OK)
|
||||
sr_dbg("%s: setting Trigger Margin to %d",
|
||||
__func__, devc->trigger_margin);
|
||||
else
|
||||
sr_dbg("%s: setting Trigger Margin to %d failed",
|
||||
__func__, devc->trigger_margin);
|
||||
} else if (id == SR_CONF_ZERO) {
|
||||
devc->zero = g_variant_get_boolean(data);
|
||||
if (devc->zero) {
|
||||
@ -1873,6 +1903,11 @@ static int dso_init(struct sr_dev_inst *sdi, gboolean from_eep)
|
||||
sr_err("Set Trigger Value command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_MARGIN));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Margin command failed!");
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -224,6 +224,7 @@ struct DSL_context {
|
||||
uint8_t trigger_hrate;
|
||||
uint32_t trigger_hpos;
|
||||
uint32_t trigger_holdoff;
|
||||
uint8_t trigger_margin;
|
||||
gboolean zero;
|
||||
gboolean cali;
|
||||
int zero_stage;
|
||||
@ -231,6 +232,7 @@ struct DSL_context {
|
||||
int zero_comb;
|
||||
gboolean stream;
|
||||
gboolean data_lock;
|
||||
uint8_t dso_bits;
|
||||
|
||||
int num_samples;
|
||||
uint64_t sent_samples;
|
||||
|
@ -146,6 +146,7 @@ static const int32_t sessions[] = {
|
||||
SR_CONF_TRIGGER_SOURCE,
|
||||
SR_CONF_HORIZ_TRIGGERPOS,
|
||||
SR_CONF_TRIGGER_HOLDOFF,
|
||||
SR_CONF_TRIGGER_MARGIN,
|
||||
};
|
||||
|
||||
static const int32_t sessions_pro[] = {
|
||||
@ -161,6 +162,7 @@ static const int32_t sessions_pro[] = {
|
||||
SR_CONF_TRIGGER_SOURCE,
|
||||
SR_CONF_HORIZ_TRIGGERPOS,
|
||||
SR_CONF_TRIGGER_HOLDOFF,
|
||||
SR_CONF_TRIGGER_MARGIN,
|
||||
};
|
||||
|
||||
static const int32_t ch_sessions[] = {
|
||||
@ -457,7 +459,7 @@ static int fpga_config(struct libusb_device_handle *hdl, const char *filename)
|
||||
struct stat f_stat;
|
||||
|
||||
sr_info("Configure FPGA using %s", filename);
|
||||
if ((fw = g_fopen(filename, "rb")) == NULL) {
|
||||
if ((fw = fopen(filename, "rb")) == NULL) {
|
||||
sr_err("Unable to open FPGA bit file %s for reading: %s",
|
||||
filename, strerror(errno));
|
||||
return SR_ERR;
|
||||
@ -701,6 +703,7 @@ static struct DSL_context *DSLogic_dev_new(void)
|
||||
devc->mstatus_valid = FALSE;
|
||||
devc->data_lock = FALSE;
|
||||
devc->max_height = 0;
|
||||
devc->dso_bits = 8;
|
||||
|
||||
return devc;
|
||||
}
|
||||
@ -999,6 +1002,10 @@ static uint64_t dso_cmd_gen(struct sr_dev_inst *sdi, struct sr_channel* ch, int
|
||||
cmd += probe->trig_value << (8 * (probe->index + 1));
|
||||
}
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MARGIN:
|
||||
cmd += 0x40;
|
||||
cmd += ((uint64_t)devc->trigger_margin << 8);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_HOLDOFF:
|
||||
cmd += 0x58;
|
||||
cmd += devc->trigger_holdoff << 8;
|
||||
@ -1013,6 +1020,63 @@ static uint64_t dso_cmd_gen(struct sr_dev_inst *sdi, struct sr_channel* ch, int
|
||||
return cmd;
|
||||
}
|
||||
|
||||
static int dso_init(struct sr_dev_inst *sdi)
|
||||
{
|
||||
int ret;
|
||||
GSList *l;
|
||||
struct sr_usb_dev_inst *usb = sdi->conn;
|
||||
|
||||
for(l = sdi->channels; l; l = l->next) {
|
||||
struct sr_channel *probe = (struct sr_channel *)l->data;
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, probe, SR_CONF_COUPLING));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("DSO set coupling of channel %d command failed!", probe->index);
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, probe, SR_CONF_VDIV));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set VDIV of channel %d command failed!", probe->index);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, 0, SR_CONF_SAMPLERATE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Sample Rate command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_HORIZ_TRIGGERPOS));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Horiz Trigger Position command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Holdoff Time command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SLOPE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Slope command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SOURCE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Source command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_VALUE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Value command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_MARGIN));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Margin command failed!");
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel *ch,
|
||||
@ -1200,6 +1264,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_uint64(devc->trigger_holdoff);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MARGIN:
|
||||
if (!sdi)
|
||||
return SR_ERR;
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_byte(devc->trigger_margin);
|
||||
break;
|
||||
case SR_CONF_ZERO:
|
||||
if (!sdi)
|
||||
return SR_ERR;
|
||||
@ -1242,6 +1312,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_uint64(DSLOGIC_MAX_LOGIC_DEPTH*ceil(samplerates[devc->samplerates_size-1] * 1.0 / DSLOGIC_MAX_LOGIC_SAMPLERATE));
|
||||
break;
|
||||
case SR_CONF_DSO_BITS:
|
||||
if (!sdi)
|
||||
return SR_ERR;
|
||||
devc = sdi->priv;
|
||||
*data = g_variant_new_byte(devc->dso_bits);
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
@ -1325,51 +1401,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
set_probes(sdi, num_probes);
|
||||
sr_dbg("%s: setting mode to %d", __func__, sdi->mode);
|
||||
if (sdi->mode == DSO) {
|
||||
GList *l;
|
||||
for(l = sdi->channels; l; l = l->next) {
|
||||
struct sr_channel *probe = (struct sr_channel *)l->data;
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, probe, SR_CONF_COUPLING));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Coupling command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, probe, SR_CONF_VDIV));
|
||||
if (ret != SR_OK) {
|
||||
sr_dbg("%s: Initial setting for DSO mode failed", __func__);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, 0, SR_CONF_SAMPLERATE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Sample Rate command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_HORIZ_TRIGGERPOS));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Horiz Trigger Position command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Holdoff Time command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SLOPE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Slope command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SOURCE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Source command failed!");
|
||||
return ret;
|
||||
}
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_VALUE));
|
||||
if (ret != SR_OK) {
|
||||
sr_err("Set Trigger Value command failed!");
|
||||
return ret;
|
||||
}
|
||||
dso_init(sdi);
|
||||
}
|
||||
} else if (id == SR_CONF_OPERATION_MODE) {
|
||||
stropt = g_variant_get_string(data, NULL);
|
||||
@ -1560,6 +1592,13 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
__func__, ch->index, ch->vdiv);
|
||||
} else if (id == SR_CONF_FACTOR) {
|
||||
ch->vfactor = g_variant_get_uint64(data);
|
||||
sr_dbg("%s: setting Factor of channel %d to %d", __func__,
|
||||
ch->index, ch->vfactor);
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_VPOS) {
|
||||
ch->vpos = g_variant_get_double(data);
|
||||
sr_dbg("%s: setting VPOS of channel %d to %lf", __func__,
|
||||
ch->index, ch->vpos);
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_TIMEBASE) {
|
||||
devc->timebase = g_variant_get_uint64(data);
|
||||
@ -1643,6 +1682,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
else
|
||||
sr_dbg("%s: setting Trigger Holdoff Time to %d failed",
|
||||
__func__, devc->trigger_holdoff);
|
||||
} else if (id == SR_CONF_TRIGGER_MARGIN) {
|
||||
devc->trigger_margin = g_variant_get_byte(data);
|
||||
if (sdi->mode == DSO) {
|
||||
ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_MARGIN));
|
||||
}
|
||||
if (ret == SR_OK)
|
||||
sr_dbg("%s: setting Trigger Margin to %d",
|
||||
__func__, devc->trigger_margin);
|
||||
else
|
||||
sr_dbg("%s: setting Trigger Margin to %d failed",
|
||||
__func__, devc->trigger_margin);
|
||||
} else if (id == SR_CONF_ZERO) {
|
||||
devc->zero = g_variant_get_boolean(data);
|
||||
ret = SR_OK;
|
||||
|
@ -110,6 +110,7 @@ struct dev_context {
|
||||
gboolean instant;
|
||||
gboolean data_lock;
|
||||
uint8_t max_height;
|
||||
uint8_t dso_bits;
|
||||
|
||||
uint16_t *buf;
|
||||
uint64_t pre_index;
|
||||
@ -345,6 +346,7 @@ static GSList *hw_scan(GSList *options)
|
||||
devc->timebase = 200;
|
||||
devc->data_lock = FALSE;
|
||||
devc->max_height = 0;
|
||||
devc->dso_bits = 8;
|
||||
|
||||
sdi->priv = devc;
|
||||
|
||||
@ -530,6 +532,9 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
case SR_CONF_RLE_SAMPLELIMITS:
|
||||
*data = g_variant_new_uint64(DEMO_MAX_LOGIC_DEPTH);
|
||||
break;
|
||||
case SR_CONF_DSO_BITS:
|
||||
*data = g_variant_new_byte(devc->dso_bits);
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
@ -655,6 +660,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_TRIGGER_HOLDOFF) {
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_TRIGGER_MARGIN) {
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_EN_CH) {
|
||||
ch->enabled = g_variant_get_boolean(data);
|
||||
sr_dbg("%s: setting ENABLE of channel %d to %d", __func__,
|
||||
@ -678,7 +685,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
ch->index, ch->vfactor);
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_VPOS) {
|
||||
ch->vpos = g_variant_get_double(data);
|
||||
//ch->vpos = g_variant_get_double(data);
|
||||
sr_dbg("%s: setting VPOS of channel %d to %lf", __func__,
|
||||
ch->index, ch->vpos);
|
||||
ret = SR_OK;
|
||||
|
@ -80,6 +80,8 @@ static struct sr_config_info sr_config_info_data[] = {
|
||||
"Horizontal trigger position", "Horizontal trigger position", NULL},
|
||||
{SR_CONF_TRIGGER_HOLDOFF, SR_T_UINT64, "triggerholdoff",
|
||||
"Trigger hold off", "Trigger hold off", NULL},
|
||||
{SR_CONF_TRIGGER_MARGIN, SR_T_UINT8, "triggermargin",
|
||||
"Trigger margin", "Trigger margin", NULL},
|
||||
{SR_CONF_BUFFERSIZE, SR_T_UINT64, "buffersize",
|
||||
"Buffer size", "Buffer size", NULL},
|
||||
{SR_CONF_TIMEBASE, SR_T_UINT64, "timebase",
|
||||
|
@ -727,6 +727,9 @@ enum {
|
||||
/** Trigger hold off time */
|
||||
SR_CONF_TRIGGER_HOLDOFF,
|
||||
|
||||
/** Trigger Margin */
|
||||
SR_CONF_TRIGGER_MARGIN,
|
||||
|
||||
/** Buffer size. */
|
||||
SR_CONF_BUFFERSIZE,
|
||||
|
||||
@ -739,6 +742,9 @@ enum {
|
||||
/** DSO configure sync */
|
||||
SR_CONF_DSO_SYNC,
|
||||
|
||||
/** DSO vertical resolution*/
|
||||
SR_CONF_DSO_BITS,
|
||||
|
||||
/** Zero */
|
||||
SR_CONF_ZERO_SET,
|
||||
SR_CONF_ZERO_LOAD,
|
||||
|
Loading…
x
Reference in New Issue
Block a user