Commit 4cc02c8d authored by DreamSourceLab's avatar DreamSourceLab

Fix trigger issue @ DSO mode

parent 5bd97eb8
......@@ -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);
......
This diff is collapsed.
......@@ -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