Commit 6c7101c2 authored by DreamSourceLab's avatar DreamSourceLab

Improve trigger commit strategy @ LA mode

parent b9e8c02c
This diff is collapsed.
......@@ -66,23 +66,21 @@ public:
QJsonObject get_session();
void set_session(QJsonObject ses);
/*
* commit trigger setting
* return 0: simple trigger
* 1: advanced trigger
*/
bool commit_trigger();
signals:
public slots:
void simple_trigger();
void adv_trigger();
void trigger_stages_changed(int index);
void widget_enable();
void widget_enable(int index);
void value_changed();
void logic_changed(int index);
void count_changed();
void inv_changed(int index);
void pos_changed(int pos);
void adv_tog(int index);
void serial_channel_changed(int index);
void device_change();
......
......@@ -414,6 +414,7 @@ void MainWindow::run_stop()
case SigSession::Stopped:
_view->show_trig_cursor(false);
_view->update_sample(false);
commit_trigger(false);
_session.start_capture(false,
boost::bind(&MainWindow::session_error, this,
QString("Capture failed"), _1));
......@@ -437,6 +438,7 @@ void MainWindow::instant_stop()
case SigSession::Stopped:
_view->show_trig_cursor(false);
_view->update_sample(true);
commit_trigger(true);
_session.start_capture(true,
boost::bind(&MainWindow::session_error, this,
QString("Capture failed"), _1));
......@@ -548,6 +550,26 @@ void MainWindow::on_trigger(bool visible)
}
}
void MainWindow::commit_trigger(bool instant)
{
ds_trigger_init();
if (_session.get_device()->dev_inst()->mode != LOGIC ||
instant)
return;
if (!_trigger_widget->commit_trigger()) {
/* simple trigger check trigger_enable */
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals())
{
assert(s);
boost::shared_ptr<view::LogicSignal> logicSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s))
logicSig->commit_trig();
}
}
}
void MainWindow::on_measure(bool visible)
{
_measure_dock->setVisible(visible);
......
......@@ -112,6 +112,8 @@ private slots:
void on_trigger(bool visible);
void commit_trigger(bool instant);
void on_measure(bool visible);
void on_search(bool visible);
......
......@@ -92,9 +92,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
_session = this;
_hot_attach = false;
_hot_detach = false;
_adv_trigger = false;
_group_cnt = 0;
ds_trigger_init();
register_hotplug_callback();
_view_timer.stop();
_view_timer.setSingleShot(true);
......@@ -563,28 +561,6 @@ void SigSession::sample_thread_proc(boost::shared_ptr<device::DevInst> dev_inst,
assert(dev_inst->dev_inst());
assert(error_handler);
if (_instant) {
/* disable trigger under instant mode */
ds_trigger_set_en(false);
} else if (!_adv_trigger) {
/* simple trigger check trigger_enable */
ds_trigger_set_en(false);
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _signals)
{
assert(s);
boost::shared_ptr<view::LogicSignal> logicSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
if (logicSig->has_trig()) {
ds_trigger_set_en(true);
logicSig->set_trig(logicSig->get_trig());
}
}
}
} else {
/* advanced trigger check trigger_enable */
ds_trigger_set_en(true);
}
try {
dev_inst->start();
} catch(const QString e) {
......@@ -1240,15 +1216,6 @@ void SigSession::stop_hotplug_proc()
_hotplug.reset();
}
/*
* Tigger
*/
void SigSession::set_adv_trigger(bool adv_trigger)
{
_adv_trigger = adv_trigger;
}
uint16_t SigSession::get_ch_num(int type)
{
uint16_t num_channels = 0;
......
......@@ -169,8 +169,6 @@ public:
void register_hotplug_callback();
void deregister_hotplug_callback();
void set_adv_trigger(bool adv_trigger);
uint16_t get_ch_num(int type);
bool get_instant();
......@@ -256,8 +254,6 @@ private:
bool _hot_attach;
bool _hot_detach;
bool _adv_trigger;
QTimer _view_timer;
QTimer _refresh_timer;
bool _data_lock;
......
......@@ -105,11 +105,6 @@ boost::shared_ptr<pv::data::Logic> LogicSignal::logic_data() const
return _data;
}
bool LogicSignal::has_trig() const
{
return (_trig != NONTRIG);
}
LogicSignal::LogicSetRegions LogicSignal::get_trig() const
{
return _trig;
......@@ -121,19 +116,26 @@ void LogicSignal::set_trig(int trig)
_trig = (LogicSetRegions)trig;
else
_trig = NONTRIG;
}
if (trig == NONTRIG)
void LogicSignal::commit_trig()
{
if (_trig == NONTRIG)
ds_trigger_probe_set(_index_list.front(), 'X', 'X');
else if (trig == POSTRIG)
else {
ds_trigger_set_en(true);
if (_trig == POSTRIG)
ds_trigger_probe_set(_index_list.front(), 'R', 'X');
else if (trig == HIGTRIG)
else if (_trig == HIGTRIG)
ds_trigger_probe_set(_index_list.front(), '1', 'X');
else if (trig == NEGTRIG)
else if (_trig == NEGTRIG)
ds_trigger_probe_set(_index_list.front(), 'F', 'X');
else if (trig == LOWTRIG)
else if (_trig == LOWTRIG)
ds_trigger_probe_set(_index_list.front(), '0', 'X');
else if (trig == EDGTRIG)
else if (_trig == EDGTRIG)
ds_trigger_probe_set(_index_list.front(), 'C', 'X');
}
}
void LogicSignal::paint_mid(QPainter &p, int left, int right)
......
......@@ -82,9 +82,9 @@ public:
/**
*
*/
bool has_trig() const;
LogicSetRegions get_trig() const;
void set_trig(int trig);
void commit_trig();
/**
* Paints the signal with a QPainter
......
......@@ -45,10 +45,12 @@ SR_API int ds_trigger_init(void)
{
int i, j;
if (!trigger) {
if (!(trigger = g_try_malloc0(sizeof(struct ds_trigger)))) {
sr_err("Trigger malloc failed.");
return SR_ERR_MALLOC;
}
}
trigger->trigger_en = 0;
trigger->trigger_mode = SIMPLE_TRIGGER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment