fix: Able to use the disabled channel for trigger

This commit is contained in:
dreamsourcelabTAI
2023-04-03 17:50:34 +08:00
parent 1eb82c3788
commit ec3b38b8cf
8 changed files with 86 additions and 10 deletions
+12
View File
@@ -291,6 +291,18 @@ void DeviceAgent::config_changed()
_callback->DeviceConfigChanged();
}
}
bool DeviceAgent::channel_is_enable(int index)
{
for (const GSList *l = get_channels(); l; l = l->next)
{
const sr_channel *const probe = (const sr_channel *)l->data;
if (probe->index == index)
return probe->enabled;
}
return false;
}
//---------------device config-----------/
+2
View File
@@ -177,6 +177,8 @@ public:
return _is_new_device;
}
bool channel_is_enable(int index);
private:
void config_changed();
bool is_in_history(ds_device_handle dev_handle);
+50
View File
@@ -37,6 +37,8 @@
#include <QEvent>
#include "../ui/langresource.h"
#include "../log.h"
#include "../ui/msgbox.h"
using namespace boost;
using namespace std;
@@ -289,9 +291,21 @@ void DsoTriggerDock::margin_changed(int margin)
void DsoTriggerDock::source_changed()
{
if (check_trig_channel() == false){
_auto_radioButton->setChecked(true);
_ch1_radioButton->setChecked(false);
_ch0a1_radioButton->setChecked(false);
_ch0o1_radioButton->setChecked(false);
QString msg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DISABLED_CHANNEL_TRIG), "Disabled channels cannot be used for triggering!"));
MsgBox::Show("", msg);
}
int id = _source_group->checkedId();
int ret;
dsv_info("Set DSO trig type:%d", id);
ret = _session->get_device()->set_config(NULL, NULL,
SR_CONF_TRIGGER_SOURCE,
g_variant_new_byte(id));
@@ -306,6 +320,42 @@ void DsoTriggerDock::source_changed()
}
}
void DsoTriggerDock::check_setting()
{
if (check_trig_channel() == false){
_auto_radioButton->setChecked(true);
_ch1_radioButton->setChecked(false);
_ch0a1_radioButton->setChecked(false);
_ch0o1_radioButton->setChecked(false);
_session->get_device()->set_config(NULL, NULL,
SR_CONF_TRIGGER_SOURCE,
g_variant_new_byte(DSO_TRIGGER_AUTO));
}
}
bool DsoTriggerDock::check_trig_channel()
{
int id = _source_group->checkedId();
bool b0 = _session->get_device()->channel_is_enable(0);
bool b1 = _session->get_device()->channel_is_enable(1);
if (DSO_TRIGGER_CH0 == id && !b0){
dsv_err("ERROR: The trigger channel is disabled");
return false;
}
else if (DSO_TRIGGER_CH1 == id && !b1){
dsv_err("ERROR: The trigger channel is disabled");
return false;
}
else if (DSO_TRIGGER_CH0A1 == id && (!b0 || !b1)){
dsv_err("ERROR: The trigger channel is disabled");
return false;
}
return true;
}
void DsoTriggerDock::channel_changed(int ch)
{
(void)ch;
+2 -2
View File
@@ -50,12 +50,14 @@ public:
void device_change();
void update_view();
void check_setting();
private:
void paintEvent(QPaintEvent *e);
void changeEvent(QEvent *event);
void retranslateUi();
void reStyle();
bool check_trig_channel();
signals:
void set_trig_pos(int percent);
@@ -71,8 +73,6 @@ private slots:
void type_changed();
void channel_changed(int ch);
private:
private:
SigSession *_session;
+5 -1
View File
@@ -1647,7 +1647,11 @@ namespace pv
break;
case DSV_MSG_START_COLLECT_WORK_PREV:
_trigger_widget->try_commit_trigger();
if (_device_agent->get_work_mode() == LOGIC)
_trigger_widget->try_commit_trigger();
else if (_device_agent->get_work_mode() == DSO)
_dso_trigger_widget->check_setting();
_view->capture_init();
_view->on_state_changed(false);
break;
+4
View File
@@ -358,5 +358,9 @@
{
"id": "IDS_MSG_TO_SWITCH_DEVICE",
"text": "要切换到新设备?"
},
{
"id": "IDS_MSG_DISABLED_CHANNEL_TRIG",
"text": "禁用通道不能用于触发!"
}
]
+4
View File
@@ -359,5 +359,9 @@
{
"id": "IDS_MSG_TO_SWITCH_DEVICE",
"text": "To switch the new device?"
},
{
"id": "IDS_MSG_DISABLED_CHANNEL_TRIG",
"text": "Disabled channels cannot be used for triggering!"
}
]
+7 -7
View File
@@ -1142,20 +1142,20 @@ struct sr_dev_mode {
enum {
SIMPLE_TRIGGER = 0,
ADV_TRIGGER,
SERIAL_TRIGGER,
ADV_TRIGGER = 1,
SERIAL_TRIGGER = 2,
};
enum {
DSO_TRIGGER_AUTO = 0,
DSO_TRIGGER_CH0,
DSO_TRIGGER_CH1,
DSO_TRIGGER_CH0A1,
DSO_TRIGGER_CH0O1,
DSO_TRIGGER_CH0 = 1,
DSO_TRIGGER_CH1 = 2,
DSO_TRIGGER_CH0A1 = 3,
DSO_TRIGGER_CH0O1 = 4,
};
enum {
DSO_TRIGGER_RISING = 0,
DSO_TRIGGER_FALLING,
DSO_TRIGGER_FALLING = 1,
};
struct ds_trigger_pos {