forked from Ivasoft/DSView
Loop mode for demo
This commit is contained in:
@@ -498,7 +498,21 @@ namespace pv
|
||||
set_operation_mode(OPT_SINGLE); // Reset the capture mode.
|
||||
}
|
||||
|
||||
if (_device_agent.is_hardware()){
|
||||
if (is_loop_mode() && _device_agent.is_demo())
|
||||
{
|
||||
GVariant *gvar = _device_agent.get_config(NULL,NULL,SR_CONF_PATTERN_MODE);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
QString rand_mode = g_variant_get_string(gvar,NULL);
|
||||
g_variant_unref(gvar);
|
||||
|
||||
if (rand_mode != "RANDOM"){
|
||||
set_operation_mode(OPT_SINGLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_device_agent.is_hardware() || _device_agent.is_demo()){
|
||||
GVariant *val = g_variant_new_boolean(is_loop_mode() && _is_stream_mode);
|
||||
_device_agent.set_config(NULL, NULL, SR_CONF_LOOP_MODE, val);
|
||||
}
|
||||
|
||||
@@ -1249,7 +1249,18 @@ namespace pv
|
||||
_is_run_as_instant = false;
|
||||
}
|
||||
|
||||
update_mode_icon();
|
||||
update_mode_icon();
|
||||
|
||||
if (_session->get_device()->is_demo() && bEnable)
|
||||
{
|
||||
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_PATTERN_MODE);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
QString rand_mode = g_variant_get_string(gvar,NULL);
|
||||
g_variant_unref(gvar);
|
||||
_action_loop->setVisible(rand_mode == "RANDOM");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ds_device_handle SamplingBar::get_next_device_handle()
|
||||
|
||||
@@ -234,6 +234,7 @@ static int scan_dsl_file(struct sr_dev_inst *sdi)
|
||||
{
|
||||
cur_sample_generator = pre_sample_generator = PATTERN_RANDOM;
|
||||
sdi->mode = LOGIC;
|
||||
g_safe_free(sdi->path);
|
||||
sdi->path = g_strdup("");
|
||||
}
|
||||
}
|
||||
@@ -400,6 +401,8 @@ static GSList *hw_scan(GSList *options)
|
||||
sdi->driver = di;
|
||||
sdi->dev_type = DEV_TYPE_DEMO;
|
||||
|
||||
vdev->is_loop = 0;
|
||||
|
||||
devices = g_slist_append(devices, sdi);
|
||||
|
||||
return devices;
|
||||
@@ -522,7 +525,6 @@ static int dev_destroy(struct sr_dev_inst *sdi)
|
||||
{
|
||||
assert(sdi);
|
||||
hw_dev_close(sdi);
|
||||
sdi->path = NULL;
|
||||
sr_dev_inst_free(sdi);
|
||||
}
|
||||
|
||||
@@ -715,19 +717,23 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
if("" != get_dsl_path_by_pattern_mode(sdi->mode,PATTERN_DEFAULT))
|
||||
{
|
||||
cur_sample_generator = pre_sample_generator = PATTERN_DEFAULT;
|
||||
g_safe_free(sdi->path);
|
||||
sdi->path = g_strdup(get_dsl_path_by_pattern_mode(sdi->mode,PATTERN_DEFAULT));
|
||||
}
|
||||
else
|
||||
{
|
||||
cur_sample_generator = pre_sample_generator = PATTERN_RANDOM;
|
||||
g_safe_free(sdi->path);
|
||||
sdi->path = g_strdup("");
|
||||
}
|
||||
break;
|
||||
case DSO:
|
||||
cur_sample_generator = pre_sample_generator = PATTERN_RANDOM;
|
||||
g_safe_free(sdi->path);
|
||||
sdi->path = g_strdup("");
|
||||
case ANALOG:
|
||||
cur_sample_generator = pre_sample_generator = PATTERN_RANDOM;
|
||||
g_safe_free(sdi->path);
|
||||
sdi->path = g_strdup("");
|
||||
default:
|
||||
break;
|
||||
@@ -753,7 +759,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ("" == (sdi->path = get_dsl_path_by_pattern_mode(sdi->mode,cur_sample_generator)) &&
|
||||
g_safe_free(sdi->path);
|
||||
sdi->path = get_dsl_path_by_pattern_mode(sdi->mode,cur_sample_generator);
|
||||
|
||||
if (sdi->path[0] == 0 &&
|
||||
cur_sample_generator != PATTERN_RANDOM)
|
||||
{
|
||||
cur_sample_generator = pre_sample_generator;
|
||||
@@ -881,6 +890,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
case SR_CONF_DEMO_INIT:
|
||||
pre_sample_generator = cur_sample_generator;
|
||||
load_virtual_device_session(sdi);
|
||||
case SR_CONF_LOOP_MODE:
|
||||
vdev->is_loop = g_variant_get_boolean(data);
|
||||
sr_info("Set demo loop mode:%d", vdev->is_loop);
|
||||
break;
|
||||
default:
|
||||
sr_err("Unknown capability: %d.", id);
|
||||
return SR_ERR_NA;
|
||||
|
||||
@@ -106,6 +106,8 @@ struct session_vdev
|
||||
uint8_t max_height;
|
||||
struct sr_status mstatus;
|
||||
struct session_packet_buffer *packet_buffer;
|
||||
|
||||
int is_loop;
|
||||
};
|
||||
|
||||
#define SESSION_MAX_CHANNEL_COUNT 512
|
||||
|
||||
Reference in New Issue
Block a user