forked from Ivasoft/DSView
The demo device can change the operation mode from toolbar button
This commit is contained in:
@@ -351,7 +351,7 @@ GSList *DeviceAgent::get_channels()
|
||||
|
||||
bool DeviceAgent::get_config_value_int16(int key, int &value)
|
||||
{
|
||||
GVariant* gvar = this->get_config(NULL, NULL, key);
|
||||
GVariant* gvar = get_config(NULL, NULL, key);
|
||||
|
||||
if (gvar != NULL) {
|
||||
value = g_variant_get_int16(gvar);
|
||||
@@ -362,8 +362,24 @@ GSList *DeviceAgent::get_channels()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeviceAgent::get_config_value_string(int key, QString &value)
|
||||
{
|
||||
GVariant* gvar = get_config(NULL, NULL, key);
|
||||
|
||||
if (gvar != NULL) {
|
||||
const gchar *s = g_variant_get_string(gvar, NULL);
|
||||
value = QString(s);
|
||||
g_variant_unref(gvar);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int DeviceAgent::get_operation_mode()
|
||||
{
|
||||
assert(_dev_handle);
|
||||
|
||||
int mode_val = 0;
|
||||
if (get_config_value_int16(SR_CONF_OPERATION_MODE, mode_val)){
|
||||
return mode_val;
|
||||
@@ -372,12 +388,14 @@ GSList *DeviceAgent::get_channels()
|
||||
}
|
||||
|
||||
bool DeviceAgent::is_stream_mode()
|
||||
{
|
||||
{
|
||||
return get_operation_mode() == LO_OP_STREAM;
|
||||
}
|
||||
|
||||
bool DeviceAgent::check_firmware_version()
|
||||
{
|
||||
assert(_dev_handle);
|
||||
|
||||
int st = -1;
|
||||
if (ds_get_actived_device_init_status(&st) == SR_OK){
|
||||
if (st == SR_ST_INCOMPATIBLE){
|
||||
@@ -387,5 +405,37 @@ GSList *DeviceAgent::get_channels()
|
||||
return true;
|
||||
}
|
||||
|
||||
QString DeviceAgent::get_demo_operation_mode()
|
||||
{
|
||||
assert(_dev_handle);
|
||||
|
||||
if (is_demo() == false){
|
||||
assert(false);
|
||||
}
|
||||
|
||||
QString pattern_mode;
|
||||
if(get_config_value_string(SR_CONF_PATTERN_MODE, pattern_mode) == false)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
return pattern_mode;
|
||||
}
|
||||
|
||||
bool DeviceAgent::set_config_string(int key, const char *value)
|
||||
{
|
||||
assert(value);
|
||||
assert(_dev_handle);
|
||||
|
||||
GVariant *gvar = g_variant_new_string(value);
|
||||
int ret = ds_set_actived_device_config(NULL, NULL, key, gvar);
|
||||
if (ret != SR_OK)
|
||||
{
|
||||
if (ret != SR_ERR_NA)
|
||||
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_string, Failed to set value of config id:", key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------device config end -----------/
|
||||
|
||||
|
||||
@@ -105,6 +105,8 @@ public:
|
||||
|
||||
bool get_config_value_int16(int key, int &value);
|
||||
|
||||
bool get_config_value_string(int key, QString &value);
|
||||
|
||||
/**
|
||||
* @brief Gets the sample limit from the driver.
|
||||
*
|
||||
@@ -183,6 +185,10 @@ public:
|
||||
|
||||
bool check_firmware_version();
|
||||
|
||||
QString get_demo_operation_mode();
|
||||
|
||||
bool set_config_string(int key, const char *value);
|
||||
|
||||
private:
|
||||
void config_changed();
|
||||
bool is_in_history(ds_device_handle dev_handle);
|
||||
|
||||
@@ -439,6 +439,7 @@ void ProtocolDock::del_all_protocol()
|
||||
}
|
||||
|
||||
_protocol_lay_items.clear();
|
||||
this->update();
|
||||
protocol_updated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
#define DSV_MSG_NEW_USB_DEVICE 6008
|
||||
#define DSV_MSG_CURRENT_DEVICE_DETACHED 6009
|
||||
#define DSV_MSG_DEVICE_CONFIG_UPDATED 6010
|
||||
#define DSV_MSG_DEMO_OPERATION_MODE_CHNAGED 6011
|
||||
|
||||
#define DSV_MSG_TRIG_NEXT_COLLECT 7001
|
||||
#define DSV_MSG_SAVE_COMPLETE 7002
|
||||
|
||||
@@ -1945,12 +1945,10 @@ namespace pv
|
||||
break;
|
||||
|
||||
case DSV_MSG_END_DEVICE_OPTIONS:
|
||||
if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){
|
||||
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_PATTERN_MODE);
|
||||
if(gvar != NULL)
|
||||
if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){
|
||||
QString pattern_mode;
|
||||
if(_device_agent->get_config_value_string(SR_CONF_PATTERN_MODE, pattern_mode))
|
||||
{
|
||||
std::string pattern_mode = g_variant_get_string(gvar,NULL);
|
||||
g_variant_unref(gvar);
|
||||
if(pattern_mode != _pattern_mode)
|
||||
{
|
||||
_pattern_mode = pattern_mode;
|
||||
@@ -1965,6 +1963,7 @@ namespace pv
|
||||
|
||||
if(_pattern_mode != "random")
|
||||
{
|
||||
_session->set_operation_mode(OPT_SINGLE);
|
||||
StoreSession ss(_session);
|
||||
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
|
||||
ss.load_decoders(_protocol_widget, deArray);
|
||||
@@ -1974,7 +1973,25 @@ namespace pv
|
||||
}
|
||||
}
|
||||
calc_min_height();
|
||||
break;
|
||||
break;
|
||||
|
||||
case DSV_MSG_DEMO_OPERATION_MODE_CHNAGED:
|
||||
if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){
|
||||
_protocol_widget->del_all_protocol();
|
||||
_session->clear_view_data();
|
||||
QString pattern_mode;
|
||||
|
||||
if(_device_agent->get_config_value_string(SR_CONF_PATTERN_MODE, pattern_mode)){
|
||||
if(pattern_mode != "random"){
|
||||
_device_agent->update();
|
||||
_session->set_operation_mode(OPT_SINGLE);
|
||||
StoreSession ss(_session);
|
||||
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
|
||||
ss.load_decoders(_protocol_widget, deArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ private:
|
||||
bool _is_auto_switch_device;
|
||||
high_resolution_clock::time_point _last_key_press_time;
|
||||
bool _is_save_confirm_msg;
|
||||
std::string _pattern_mode;
|
||||
QString _pattern_mode;
|
||||
QWidget *_frame;
|
||||
DsTimer _delay_prop_msg_timer;
|
||||
QString _strMsg;
|
||||
|
||||
@@ -2296,4 +2296,10 @@ namespace pv
|
||||
set_cur_samplelimits(_device_agent.get_sample_limit());
|
||||
}
|
||||
|
||||
void SigSession::clear_view_data()
|
||||
{
|
||||
_view_data->clear();
|
||||
data_updated();
|
||||
}
|
||||
|
||||
} // namespace pv
|
||||
|
||||
@@ -416,6 +416,8 @@ public:
|
||||
return _is_action;
|
||||
}
|
||||
|
||||
void clear_view_data();
|
||||
|
||||
private:
|
||||
void set_cur_samplelimits(uint64_t samplelimits);
|
||||
void set_cur_snap_samplerate(uint64_t samplerate);
|
||||
|
||||
@@ -133,9 +133,9 @@ namespace pv
|
||||
connect(&_run_stop_button, SIGNAL(clicked()), this, SLOT(on_run_stop()), Qt::DirectConnection);
|
||||
connect(&_instant_button, SIGNAL(clicked()), this, SLOT(on_instant_stop()));
|
||||
connect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int)));
|
||||
connect(_action_single, SIGNAL(triggered()), this, SLOT(on_mode()));
|
||||
connect(_action_repeat, SIGNAL(triggered()), this, SLOT(on_mode()));
|
||||
connect(_action_loop, SIGNAL(triggered()), this, SLOT(on_mode()));
|
||||
connect(_action_single, SIGNAL(triggered()), this, SLOT(on_collect_mode()));
|
||||
connect(_action_repeat, SIGNAL(triggered()), this, SLOT(on_collect_mode()));
|
||||
connect(_action_loop, SIGNAL(triggered()), this, SLOT(on_collect_mode()));
|
||||
connect(&_sample_rate, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplerate_sel(int)));
|
||||
}
|
||||
|
||||
@@ -1092,14 +1092,19 @@ namespace pv
|
||||
update();
|
||||
}
|
||||
|
||||
void SamplingBar::on_mode()
|
||||
void SamplingBar::on_collect_mode()
|
||||
{
|
||||
QString iconPath = GetIconPath();
|
||||
QAction *act = qobject_cast<QAction *>(sender());
|
||||
|
||||
if (act == _action_single)
|
||||
{
|
||||
{
|
||||
_session->set_operation_mode(OPT_SINGLE);
|
||||
|
||||
if (_device_agent->is_demo()){
|
||||
_device_agent->set_config_string(SR_CONF_PATTERN_MODE, "protocol");
|
||||
_session->broadcast_msg(DSV_MSG_DEMO_OPERATION_MODE_CHNAGED);
|
||||
}
|
||||
}
|
||||
else if (act == _action_repeat)
|
||||
{
|
||||
@@ -1118,12 +1123,23 @@ namespace pv
|
||||
{
|
||||
_session->set_repeat_intvl(interval_dlg.get_interval());
|
||||
_session->set_operation_mode(OPT_REPEAT);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_device_agent->is_demo()){
|
||||
_device_agent->set_config_string(SR_CONF_PATTERN_MODE, "random");
|
||||
_session->broadcast_msg(DSV_MSG_DEMO_OPERATION_MODE_CHNAGED);
|
||||
}
|
||||
}
|
||||
else if (act == _action_loop)
|
||||
{
|
||||
{
|
||||
_session->set_operation_mode(OPT_LOOP);
|
||||
|
||||
if (_device_agent->is_demo()){
|
||||
_device_agent->set_config_string(SR_CONF_PATTERN_MODE, "random");
|
||||
_session->broadcast_msg(DSV_MSG_DEMO_OPERATION_MODE_CHNAGED);
|
||||
}
|
||||
}
|
||||
|
||||
update_mode_icon();
|
||||
@@ -1222,7 +1238,7 @@ namespace pv
|
||||
}
|
||||
}
|
||||
|
||||
if (_device_agent->have_instance()){
|
||||
if (mode == LOGIC && _device_agent->is_file() == false){
|
||||
if (_device_agent->is_stream_mode() || _device_agent->is_demo())
|
||||
_action_loop->setVisible(true);
|
||||
}
|
||||
@@ -1261,7 +1277,6 @@ namespace pv
|
||||
g_variant_unref(gvar);
|
||||
|
||||
bool is_rand = rand_mode == "random";
|
||||
_action_loop->setVisible(is_rand);
|
||||
|
||||
if (!is_rand && mode == LOGIC){
|
||||
_sample_rate.setEnabled(false);
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace pv
|
||||
void update_mode_icon();
|
||||
|
||||
private slots:
|
||||
void on_mode();
|
||||
void on_collect_mode();
|
||||
void on_run_stop();
|
||||
void on_instant_stop();
|
||||
void on_device_selected();
|
||||
|
||||
Reference in New Issue
Block a user