hameg-hmo: Reduce unnecessarily high nesting level.
This commit is contained in:
parent
719eff68ad
commit
082972e8c5
|
@ -353,11 +353,11 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
return SR_ERR_PROBE_GROUP;
|
return SR_ERR_PROBE_GROUP;
|
||||||
} else if (pg_type == PG_ANALOG) {
|
} else if (pg_type == PG_ANALOG) {
|
||||||
for (i = 0; i < model->analog_channels; ++i) {
|
for (i = 0; i < model->analog_channels; ++i) {
|
||||||
if (probe_group == &devc->analog_groups[i]) {
|
if (probe_group != &devc->analog_groups[i])
|
||||||
*data = g_variant_new_int32(model->num_ydivs);
|
continue;
|
||||||
ret = SR_OK;
|
*data = g_variant_new_int32(model->num_ydivs);
|
||||||
break;
|
ret = SR_OK;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,15 +422,15 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
case SR_CONF_TRIGGER_SOURCE:
|
case SR_CONF_TRIGGER_SOURCE:
|
||||||
tmp = g_variant_get_string(data, NULL);
|
tmp = g_variant_get_string(data, NULL);
|
||||||
for (i = 0; (*model->trigger_sources)[i]; i++) {
|
for (i = 0; (*model->trigger_sources)[i]; i++) {
|
||||||
if (!g_strcmp0(tmp, (*model->trigger_sources)[i])) {
|
if (g_strcmp0(tmp, (*model->trigger_sources)[i]) != 0)
|
||||||
state->trigger_source = i;
|
continue;
|
||||||
g_snprintf(command, sizeof(command),
|
state->trigger_source = i;
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
|
g_snprintf(command, sizeof(command),
|
||||||
(*model->trigger_sources)[i]);
|
(*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
|
||||||
|
(*model->trigger_sources)[i]);
|
||||||
|
|
||||||
ret = sr_scpi_send(sdi->conn, command);
|
ret = sr_scpi_send(sdi->conn, command);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VDIV:
|
case SR_CONF_VDIV:
|
||||||
|
@ -442,42 +442,42 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
g_variant_get(data, "(tt)", &p, &q);
|
g_variant_get(data, "(tt)", &p, &q);
|
||||||
|
|
||||||
for (i = 0; i < model->num_vdivs; i++) {
|
for (i = 0; i < model->num_vdivs; i++) {
|
||||||
if (p == (*model->vdivs)[i][0] &&
|
if (p != (*model->vdivs)[i][0] ||
|
||||||
q == (*model->vdivs)[i][1]) {
|
q != (*model->vdivs)[i][1])
|
||||||
for (j = 1; j <= model->analog_channels; ++j) {
|
continue;
|
||||||
if (probe_group == &devc->analog_groups[j - 1]) {
|
for (j = 1; j <= model->analog_channels; ++j) {
|
||||||
state->analog_channels[j - 1].vdiv = (float) p / q;
|
if (probe_group != &devc->analog_groups[j - 1])
|
||||||
g_snprintf(command, sizeof(command),
|
continue;
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV],
|
state->analog_channels[j - 1].vdiv = (float) p / q;
|
||||||
j, state->analog_channels[j-1].vdiv);
|
g_snprintf(command, sizeof(command),
|
||||||
|
(*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV],
|
||||||
|
j, state->analog_channels[j-1].vdiv);
|
||||||
|
|
||||||
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
|
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
|
||||||
sr_scpi_get_opc(sdi->conn) != SR_OK)
|
sr_scpi_get_opc(sdi->conn) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = SR_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TIMEBASE:
|
case SR_CONF_TIMEBASE:
|
||||||
g_variant_get(data, "(tt)", &p, &q);
|
g_variant_get(data, "(tt)", &p, &q);
|
||||||
|
|
||||||
for (i = 0; i < model->num_timebases; i++) {
|
for (i = 0; i < model->num_timebases; i++) {
|
||||||
if (p == (*model->timebases)[i][0] &&
|
if (p != (*model->timebases)[i][0] ||
|
||||||
q == (*model->timebases)[i][1]) {
|
q != (*model->timebases)[i][1])
|
||||||
state->timebase = (float) p / q;
|
continue;
|
||||||
g_snprintf(command, sizeof(command),
|
state->timebase = (float) p / q;
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
|
g_snprintf(command, sizeof(command),
|
||||||
state->timebase);
|
(*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
|
||||||
|
state->timebase);
|
||||||
|
|
||||||
ret = sr_scpi_send(sdi->conn, command);
|
ret = sr_scpi_send(sdi->conn, command);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_HORIZ_TRIGGERPOS:
|
case SR_CONF_HORIZ_TRIGGERPOS:
|
||||||
|
@ -516,25 +516,25 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
tmp = g_variant_get_string(data, NULL);
|
tmp = g_variant_get_string(data, NULL);
|
||||||
|
|
||||||
for (i = 0; (*model->coupling_options)[i]; i++) {
|
for (i = 0; (*model->coupling_options)[i]; i++) {
|
||||||
if (!strcmp(tmp, (*model->coupling_options)[i])) {
|
if (strcmp(tmp, (*model->coupling_options)[i]) != 0)
|
||||||
for (j = 1; j <= model->analog_channels; ++j) {
|
continue;
|
||||||
if (probe_group == &devc->analog_groups[j - 1]) {
|
for (j = 1; j <= model->analog_channels; ++j) {
|
||||||
state->analog_channels[j-1].coupling = i;
|
if (probe_group != &devc->analog_groups[j - 1])
|
||||||
|
continue;
|
||||||
|
state->analog_channels[j-1].coupling = i;
|
||||||
|
|
||||||
g_snprintf(command, sizeof(command),
|
g_snprintf(command, sizeof(command),
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_COUPLING],
|
(*model->scpi_dialect)[SCPI_CMD_SET_COUPLING],
|
||||||
j, tmp);
|
j, tmp);
|
||||||
|
|
||||||
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
|
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
|
||||||
sr_scpi_get_opc(sdi->conn) != SR_OK)
|
sr_scpi_get_opc(sdi->conn) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = SR_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -692,15 +692,15 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi)
|
||||||
probe = l->data;
|
probe = l->data;
|
||||||
switch (probe->type) {
|
switch (probe->type) {
|
||||||
case SR_PROBE_ANALOG:
|
case SR_PROBE_ANALOG:
|
||||||
if (probe->enabled != state->analog_channels[probe->index].state) {
|
if (probe->enabled == state->analog_channels[probe->index].state)
|
||||||
g_snprintf(command, sizeof(command),
|
break;
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
|
g_snprintf(command, sizeof(command),
|
||||||
probe->index + 1, probe->enabled);
|
(*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
|
||||||
|
probe->index + 1, probe->enabled);
|
||||||
|
|
||||||
if (sr_scpi_send(serial, command) != SR_OK)
|
if (sr_scpi_send(serial, command) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
state->analog_channels[probe->index].state = probe->enabled;
|
state->analog_channels[probe->index].state = probe->enabled;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SR_PROBE_LOGIC:
|
case SR_PROBE_LOGIC:
|
||||||
/*
|
/*
|
||||||
|
@ -710,16 +710,16 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi)
|
||||||
if (probe->enabled)
|
if (probe->enabled)
|
||||||
pod_enabled[probe->index < 8 ? 0 : 1] = TRUE;
|
pod_enabled[probe->index < 8 ? 0 : 1] = TRUE;
|
||||||
|
|
||||||
if (probe->enabled != state->digital_channels[probe->index]) {
|
if (probe->enabled == state->digital_channels[probe->index])
|
||||||
g_snprintf(command, sizeof(command),
|
break;
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
|
g_snprintf(command, sizeof(command),
|
||||||
probe->index, probe->enabled);
|
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
|
||||||
|
probe->index, probe->enabled);
|
||||||
|
|
||||||
if (sr_scpi_send(serial, command) != SR_OK)
|
if (sr_scpi_send(serial, command) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
state->digital_channels[probe->index] = probe->enabled;
|
state->digital_channels[probe->index] = probe->enabled;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
@ -727,16 +727,14 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i <= model->digital_pods; ++i) {
|
for (i = 1; i <= model->digital_pods; ++i) {
|
||||||
if (state->digital_pods[i - 1] != pod_enabled[i - 1]) {
|
if (state->digital_pods[i - 1] == pod_enabled[i - 1])
|
||||||
g_snprintf(command, sizeof(command),
|
continue;
|
||||||
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_POD_STATE],
|
g_snprintf(command, sizeof(command),
|
||||||
i, pod_enabled[i - 1]);
|
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_POD_STATE],
|
||||||
|
i, pod_enabled[i - 1]);
|
||||||
if (sr_scpi_send(serial, command) != SR_OK)
|
if (sr_scpi_send(serial, command) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
state->digital_pods[i - 1] = pod_enabled[i - 1];
|
||||||
state->digital_pods[i - 1] = pod_enabled[i - 1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(pod_enabled);
|
g_free(pod_enabled);
|
||||||
|
@ -761,14 +759,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
for (l = sdi->probes; l; l = l->next) {
|
for (l = sdi->probes; l; l = l->next) {
|
||||||
probe = l->data;
|
probe = l->data;
|
||||||
if (probe->enabled) {
|
if (!probe->enabled)
|
||||||
/* Only add a single digital probe. */
|
continue;
|
||||||
if (probe->type != SR_PROBE_LOGIC || !digital_added) {
|
/* Only add a single digital probe. */
|
||||||
devc->enabled_probes = g_slist_append(
|
if (probe->type != SR_PROBE_LOGIC || !digital_added) {
|
||||||
devc->enabled_probes, probe);
|
devc->enabled_probes = g_slist_append(
|
||||||
if (probe->type == SR_PROBE_LOGIC)
|
devc->enabled_probes, probe);
|
||||||
digital_added = TRUE;
|
if (probe->type == SR_PROBE_LOGIC)
|
||||||
}
|
digital_added = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue