Commit 6c7101c2 authored by DreamSourceLab's avatar DreamSourceLab
Browse files

Improve trigger commit strategy @ LA mode

parent b9e8c02c
......@@ -147,11 +147,6 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
connect(_value0_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
connect(_value1_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
connect(_logic_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(logic_changed(int)));
connect(_inv0_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(inv_changed(int)));
connect(_inv1_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(inv_changed(int)));
connect(_count0_spinBox, SIGNAL(editingFinished()), this, SLOT(count_changed()));
connect(_count1_spinBox, SIGNAL(editingFinished()), this, SLOT(count_changed()));
}
_serial_start_label = new QLabel(tr("Start Flag: "), _widget);
......@@ -221,7 +216,6 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
connect(_serial_start_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
connect(_serial_stop_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
connect(_serial_edge_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
connect(_serial_data_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(serial_channel_changed(int)));
connect(_serial_value_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
......@@ -233,9 +227,8 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
connect(simple_radioButton, SIGNAL(clicked()), this, SLOT(simple_trigger()));
connect(adv_radioButton, SIGNAL(clicked()), this, SLOT(adv_trigger()));
connect(stages_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(trigger_stages_changed(int)));
connect(position_slider, SIGNAL(valueChanged(int)), this, SLOT(pos_changed(int)));
connect(_adv_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(adv_tog(int)));
connect(stages_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(widget_enable(int)));
QVBoxLayout *layout = new QVBoxLayout(_widget);
QGridLayout *gLayout = new QGridLayout();
......@@ -278,21 +271,6 @@ void TriggerDock::simple_trigger()
stages_label->setDisabled(true);
stages_comboBox->setDisabled(true);
_adv_tabWidget->setDisabled(true);
for (i = 0; i < TriggerStages; i++) {
stage_tabWidget->setTabEnabled(i, true);
// _mu_label_list.at(i)->setDisabled(true);
// _logic_comboBox_list.at(i)->setDisabled(true);
// _value0_lineEdit_list.at(i)->setDisabled(true);
// _count0_spinBox_list.at(i)->setDisabled(true);
// _inv0_comboBox_list.at(i)->setDisabled(true);
// _value1_lineEdit_list.at(i)->setDisabled(true);
// _count1_spinBox_list.at(i)->setDisabled(true);
// _inv1_comboBox_list.at(i)->setDisabled(true);
}
ds_trigger_set_mode(SIMPLE_TRIGGER);
_session.set_adv_trigger(false);
}
void TriggerDock::adv_trigger()
......@@ -313,12 +291,7 @@ void TriggerDock::adv_trigger()
msg.exec();
simple_radioButton->setChecked(true);
} else {
widget_enable();
if (_adv_tabWidget->currentIndex() == 0)
ds_trigger_set_mode(ADV_TRIGGER);
else if (_adv_tabWidget->currentIndex() == 1)
ds_trigger_set_mode(SERIAL_TRIGGER);
_session.set_adv_trigger(true);
widget_enable(0);
}
} else {
QMessageBox msg(this);
......@@ -331,18 +304,10 @@ void TriggerDock::adv_trigger()
}
}
void TriggerDock::trigger_stages_changed(int index)
void TriggerDock::widget_enable(int index)
{
widget_enable();
ds_trigger_set_stage(index);
value_changed();
logic_changed(0);
inv_changed(0);
count_changed();
}
(void) index;
void TriggerDock::widget_enable()
{
int i;
int enable_stages;
stages_label->setDisabled(false);
......@@ -352,143 +317,23 @@ void TriggerDock::widget_enable()
enable_stages = stages_comboBox->currentText().toInt();
for (i = 0; i < enable_stages; i++) {
stage_tabWidget->setTabEnabled(i, true);
// _mu_label_list.at(i)->setVisible(true);
// _mu_label_list.at(i)->setDisabled(false);
// _logic_comboBox_list.at(i)->setVisible(true);
// _logic_comboBox_list.at(i)->setDisabled(false);
// _value0_lineEdit_list.at(i)->setVisible(true);
// _value0_lineEdit_list.at(i)->setDisabled(false);
// _count0_spinBox_list.at(i)->setVisible(true);
// _count0_spinBox_list.at(i)->setDisabled(false);
// _inv0_comboBox_list.at(i)->setVisible(true);
// _inv0_comboBox_list.at(i)->setDisabled(false);
// _value1_lineEdit_list.at(i)->setVisible(true);
// _value1_lineEdit_list.at(i)->setDisabled(false);
// _count1_spinBox_list.at(i)->setVisible(true);
// _count1_spinBox_list.at(i)->setDisabled(false);
// _inv1_comboBox_list.at(i)->setVisible(true);
// _inv1_comboBox_list.at(i)->setDisabled(false);
}
for (i = enable_stages; i < TriggerStages; i++) {
stage_tabWidget->setTabEnabled(i, false);
// _mu_label_list.at(i)->setVisible(false);
// _logic_comboBox_list.at(i)->setVisible(false);
// _value0_lineEdit_list.at(i)->setVisible(false);
// _count0_spinBox_list.at(i)->setVisible(false);
// _inv0_comboBox_list.at(i)->setVisible(false);
// _value1_lineEdit_list.at(i)->setVisible(false);
// _count1_spinBox_list.at(i)->setVisible(false);
// _inv1_comboBox_list.at(i)->setVisible(false);
}
}
void TriggerDock::value_changed()
{
int i;
if (_adv_tabWidget->currentIndex() == 0) {
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
_value0_lineEdit_list.at(i)->setText(_value0_lineEdit_list.at(i)->text().toUpper());
while(_value0_lineEdit_list.at(i)->text().length() < TriggerProbes)
_value0_lineEdit_list.at(i)->setText("X" + _value0_lineEdit_list.at(i)->text());
_value1_lineEdit_list.at(i)->setText(_value1_lineEdit_list.at(i)->text().toUpper());
while(_value1_lineEdit_list.at(i)->text().length() < TriggerProbes)
_value1_lineEdit_list.at(i)->setText("X" + _value1_lineEdit_list.at(i)->text());
ds_trigger_stage_set_value(i, TriggerProbes,
_value0_lineEdit_list.at(i)->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(i)->text().toLocal8Bit().data());
}
} else if(_adv_tabWidget->currentIndex() == 1){
_serial_start_lineEdit->setText(_serial_start_lineEdit->text().toUpper());
ds_trigger_stage_set_value(0, TriggerProbes,
_serial_start_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(0)->text().toLocal8Bit().data());
_serial_stop_lineEdit->setText(_serial_stop_lineEdit->text().toUpper());
ds_trigger_stage_set_value(1, TriggerProbes,
_serial_stop_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(1)->text().toLocal8Bit().data());
_serial_edge_lineEdit->setText(_serial_edge_lineEdit->text().toUpper());
ds_trigger_stage_set_value(2, TriggerProbes,
_serial_edge_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(2)->text().toLocal8Bit().data());
//_serial_data_comboBox
const int data_channel = _serial_data_comboBox->currentText().toInt();
char channel[31];
for(i = 0; i < 31; i++){
if (i == (30 - 2*data_channel))
channel[i] = '1';
else if (i%2 == 0)
channel[i] = '0';
else
channel[i] = ' ';
}
ds_trigger_stage_set_value(3, TriggerProbes,
channel,
_value1_lineEdit_list.at(3)->text().toLocal8Bit().data());
_serial_value_lineEdit->setText(_serial_value_lineEdit->text().toUpper());
ds_trigger_stage_set_value(4, TriggerProbes,
_serial_value_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(4)->text().toLocal8Bit().data());
}
}
void TriggerDock::serial_channel_changed(int index)
{
(void)index;
value_changed();
}
void TriggerDock::logic_changed(int index)
{
(void)index;
int i;
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_logic(i, TriggerProbes,
_logic_comboBox_list.at(i)->currentIndex());
}
}
void TriggerDock::inv_changed(int index)
{
(void)index;
int i;
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_inv(i, TriggerProbes,
_inv0_comboBox_list.at(i)->currentIndex(),
_inv1_comboBox_list.at(i)->currentIndex());
}
}
void TriggerDock::count_changed()
{
int i;
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_count(i, TriggerProbes,
_count0_spinBox_list.at(i)->value() - 1,
_count1_spinBox_list.at(i)->value() - 1);
}
}
void TriggerDock::pos_changed(int pos)
{
ds_trigger_set_pos(pos);
QLineEdit* sc=dynamic_cast<QLineEdit*>(sender());
if(sc != NULL)
sc->setText(sc->text().toUpper());
}
void TriggerDock::device_change()
{
uint64_t max_hd_depth;
bool stream;
bool stream = false;
uint8_t maxRange;
uint64_t sample_limits;
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MAX_LOGIC_SAMPLELIMITS);
......@@ -504,34 +349,101 @@ void TriggerDock::device_change()
maxRange = max_hd_depth*70 / sample_limits;
position_spinBox->setRange(0, maxRange);
position_slider->setRange(0, maxRange);
simple_radioButton->setChecked(true);
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
if (gvar != NULL) {
stream = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (stream)
simple_trigger();
}
if (!strncmp(_session.get_device()->dev_inst()->driver->name, "virtual", 7) ||
stream) {
simple_radioButton->setChecked(true);
simple_trigger();
}
}
}
}
void TriggerDock::adv_tog(int index)
bool TriggerDock::commit_trigger()
{
if(index == 0) {
stages_label->setDisabled(false);
stages_comboBox->setDisabled(false);
ds_trigger_set_mode(ADV_TRIGGER);
} else if (index == 1) {
stages_label->setDisabled(true);
stages_comboBox->setDisabled(true);
ds_trigger_set_mode(SERIAL_TRIGGER);
// trigger position update
ds_trigger_set_pos(position_slider->value());
// trigger mode update
if (simple_radioButton->isChecked()) {
ds_trigger_set_mode(SIMPLE_TRIGGER);
return 0;
} else {
ds_trigger_set_en(true);
if (_adv_tabWidget->currentIndex() == 0)
ds_trigger_set_mode(ADV_TRIGGER);
else if (_adv_tabWidget->currentIndex() == 1)
ds_trigger_set_mode(SERIAL_TRIGGER);
// trigger stage update
ds_trigger_set_stage(stages_comboBox->currentText().toInt());
int i;
// trigger value update
if (_adv_tabWidget->currentIndex() == 0) {
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_value(i, TriggerProbes,
_value0_lineEdit_list.at(i)->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(i)->text().toLocal8Bit().data());
}
} else if(_adv_tabWidget->currentIndex() == 1){
ds_trigger_stage_set_value(0, TriggerProbes,
_serial_start_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(0)->text().toLocal8Bit().data());
ds_trigger_stage_set_value(1, TriggerProbes,
_serial_stop_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(1)->text().toLocal8Bit().data());
ds_trigger_stage_set_value(2, TriggerProbes,
_serial_edge_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(2)->text().toLocal8Bit().data());
//_serial_data_comboBox
const int data_channel = _serial_data_comboBox->currentText().toInt();
char channel[31];
for(i = 0; i < 31; i++){
if (i == (30 - 2*data_channel))
channel[i] = '1';
else if (i%2 == 0)
channel[i] = '0';
else
channel[i] = ' ';
}
ds_trigger_stage_set_value(3, TriggerProbes,
channel,
_value1_lineEdit_list.at(3)->text().toLocal8Bit().data());
ds_trigger_stage_set_value(4, TriggerProbes,
_serial_value_lineEdit->text().toLocal8Bit().data(),
_value1_lineEdit_list.at(4)->text().toLocal8Bit().data());
}
// trigger logic update
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_logic(i, TriggerProbes,
_logic_comboBox_list.at(i)->currentIndex());
}
// trigger inv update
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_inv(i, TriggerProbes,
_inv0_comboBox_list.at(i)->currentIndex(),
_inv1_comboBox_list.at(i)->currentIndex());
}
// trigger count update
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
ds_trigger_stage_set_count(i, TriggerProbes,
_count0_spinBox_list.at(i)->value() - 1,
_count1_spinBox_list.at(i)->value() - 1);
}
return 1;
}
value_changed();
logic_changed(0);
inv_changed(0);
count_changed();
}
void TriggerDock::init()
......@@ -607,11 +519,6 @@ void TriggerDock::set_session(QJsonObject ses)
_serial_edge_lineEdit->setText(ses["triggerClock"].toString());
_serial_data_comboBox->setCurrentIndex(ses["triggerChannel"].toDouble());
_serial_value_lineEdit->setText(ses["triggerData"].toString());
value_changed();
logic_changed(0);
inv_changed(0);
count_changed();
}
} // namespace dock
......
......@@ -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)
ds_trigger_probe_set(_index_list.front(), 'R', 'X');
else if (trig == HIGTRIG)
ds_trigger_probe_set(_index_list.front(), '1', 'X');
else if (trig == NEGTRIG)
ds_trigger_probe_set(_index_list.front(), 'F', 'X');
else if (trig == LOWTRIG)
ds_trigger_probe_set(_index_list.front(), '0', 'X');
else if (trig == EDGTRIG)
ds_trigger_probe_set(_index_list.front(), 'C', 'X');
else {
ds_trigger_set_en(true);
if (_trig == POSTRIG)
ds_trigger_probe_set(_index_list.front(), 'R', 'X');
else if (_trig == HIGTRIG)
ds_trigger_probe_set(_index_list.front(), '1', 'X');
else if (_trig == NEGTRIG)
ds_trigger_probe_set(_index_list.front(), 'F', 'X');
else if (_trig == LOWTRIG)
ds_trigger_probe_set(_index_list.front(), '0', 'X');
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,9 +45,11 @@ SR_API int ds_trigger_init(void)
{
int i, j;
if (!(trigger = g_try_malloc0(sizeof(struct ds_trigger)))) {
sr_err("Trigger malloc failed.");
return SR_ERR_MALLOC;
if (!trigger) {
if (!(trigger = g_try_malloc0(sizeof(struct ds_trigger)))) {
sr_err("Trigger malloc failed.");
return SR_ERR_MALLOC;
}
}
trigger->trigger_en = 0;
......
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