/* Set the sample rate, either directly or by inference by the number of points specified. * If both are specified, then sample rate takes precedence. Returns the actual sample rate. */ double lecroy_set_sample_rate(VXI11_CLINK * clink, double s_rate, long n_points, long timeout) { double actual_s_rate; double expected_s_rate; double time_range; if (n_points > 0) { time_range = vxi11_obtain_double_value_timeout(clink, "TIME_DIV?", timeout) * 10.0; expected_s_rate = (double)n_points / time_range; vxi11_send_printf(clink, "VBS 'app.Acquisition.Horizontal.SampleRate=%g'", expected_s_rate); } if (s_rate > 0) { vxi11_send_printf(clink, "VBS 'app.Acquisition.Horizontal.SampleRate=%g'", s_rate); } actual_s_rate = vxi11_obtain_double_value_timeout(clink, "VBS? 'Return=app.Acquisition.Horizontal.SampleRate'", timeout); return actual_s_rate; }
/* Lazy wrapper function with default read timeout */ double vxi11_obtain_double_value(CLINK *clink, const char *cmd) { return vxi11_obtain_double_value_timeout(clink, cmd, VXI11_READ_TIMEOUT); }
long lecroy_write_wfi_file(VXI11_CLINK * clink, char *wfiname, char chan, char *captured_by, int no_of_traces, int bytes_per_point, long no_of_bytes, unsigned long timeout, int force_voffset, double voffset) { FILE *wfi; double vgain, hinterval, hoffset; int ret; char cmd[256]; char source[20]; int no_of_segments; lecroy_scope_channel_str(chan, source); // VBS commands return quicker than INSP? commands, so where there is a // direct equivalent they are used instead to speed things up // sprintf(cmd, "%s:INSP? HORIZ_INTERVAL", source); // hinterval = lecroy_obtain_insp_double(clink, cmd, timeout); sprintf(cmd, "VBS? 'Return=app.Acquisition.Horizontal.TimePerPoint'"); hinterval = vxi11_obtain_double_value_timeout(clink, cmd, timeout); sprintf(cmd, "%s:INSP? HORIZ_OFFSET", source); hoffset = lecroy_obtain_insp_double(clink, cmd, timeout); sprintf(cmd, "%s:INSP? VERTICAL_GAIN", source); vgain = lecroy_obtain_insp_double(clink, cmd, timeout); if (force_voffset == 0) { sprintf(cmd, "%s:INSP? VERTICAL_OFFSET", source); voffset = lecroy_obtain_insp_double(clink, cmd, timeout); } //sprintf(cmd, "VBS? 'Return=app.Acquisition.%s.VerOffset'", source); // commented out as this doesn't work for maths channels //voffset = vxi11_obtain_double_value_timeout(clink, cmd, timeout); if (lecroy_is_maths_chan(chan) == 0) { no_of_segments = lecroy_get_segmented(clink); // returns 1 if not in segmented mode } else { no_of_segments = 1; } wfi = fopen(wfiname, "w"); if (wfi > 0) { fprintf(wfi, "%% %s\n", wfiname); fprintf(wfi, "%% Waveform captured using %s\n\n", captured_by); if (no_of_segments == 0) { fprintf(wfi, "%% Number of bytes:\n%d\n\n", no_of_bytes); } else { fprintf(wfi, "%% Number of bytes:\n%d\n\n", (no_of_bytes / no_of_segments)); } fprintf(wfi, "%% Vertical gain:\n%g\n\n", vgain); fprintf(wfi, "%% Vertical offset:\n%g\n\n", voffset); fprintf(wfi, "%% Horizontal interval:\n%g\n\n", hinterval); fprintf(wfi, "%% Horizontal offset:\n%g\n\n", hoffset); if (no_of_segments == 0) { fprintf(wfi, "%% Number of traces:\n%d\n\n", no_of_traces); } else { fprintf(wfi, "%% Number of traces:\n%d\n\n", (no_of_traces * no_of_segments)); } fprintf(wfi, "%% Number of bytes per data-point:\n%d\n\n", bytes_per_point); fprintf(wfi, "%% Keep all datapoints (0 or missing knocks off 1 point, legacy lecroy):\n%d\n\n", 1); fclose(wfi); } else { printf ("error: lecroy_write_wfi_file: could not open %s for writing\n", wfiname); return -1; } return no_of_bytes; }