- g_variant_get(data, "(tt)", &p, &q);
-
- for (i = 0; i < model->num_vdivs; i++) {
- if (p != model->vdivs[i].p || q != model->vdivs[i].q)
- continue;
- for (j = 1; j <= model->analog_channels; j++) {
- if (cg != devc->analog_groups[j - 1])
- continue;
- state->analog_channels[j - 1].vdiv = i;
- g_snprintf(command, sizeof(command),
- "C%d:VDIV %E", j, (float)p/q);
-
- if (sr_scpi_send(sdi->conn, command) != SR_OK ||
- sr_scpi_get_opc(sdi->conn) != SR_OK)
- return SR_ERR;
-
- break;
- }
-
- ret = SR_OK;
- break;
- }
+ if ((idx = std_u64_tuple_idx(data, *model->vdivs, model->num_vdivs)) < 0)
+ return SR_ERR_ARG;
+ if ((j = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
+ return SR_ERR_ARG;
+ state->analog_channels[j].vdiv = idx;
+ g_snprintf(command, sizeof(command),
+ "C%d:VDIV %E", j + 1, (float) (*model->vdivs)[idx][0] / (*model->vdivs)[idx][1]);
+ if (sr_scpi_send(sdi->conn, command) != SR_OK || sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ ret = SR_OK;