From 1574729632acebdcdf8caa025dcb67c6ac3804fc Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sat, 19 Jun 2010 18:28:47 +0200 Subject: [PATCH 1/1] add vertical status information --- rigold.c | 71 ++++++++++++++++++++++++++++---------------------------- scope.c | 34 +++++++++++++++++++++++++++ scope.h | 11 ++++++++- 3 files changed, 80 insertions(+), 36 deletions(-) diff --git a/rigold.c b/rigold.c index c399dc5..d8e4b19 100644 --- a/rigold.c +++ b/rigold.c @@ -60,6 +60,9 @@ static int send_command_output(int s, struct scope *sc, char *cmd) static void serve_index(int s, struct scope *sc, char *param) { + int i; + struct channel_s *ch; + send_text(s, "HTTP/1.0 200 OK\n"); send_text(s, "Content-type: text/html\n\n"); send_text(s, "%s\n", scope_idn(sc)); @@ -68,6 +71,7 @@ static void serve_index(int s, struct scope *sc, char *param) claimscope(sc); update_scope_status(sc); + releasescope(sc); send_text(s, "System: Language: %s, Counter: %d, Beep: %d

\n", sc->status.system.lang, @@ -112,18 +116,6 @@ static void serve_index(int s, struct scope *sc, char *param) sc->status.measure.ch1.pdelay, sc->status.measure.ch1.ndelay); - send_text(s, "Acquire: Type: %s, Mode: %s, Averages: %d
\n", - sc->status.acquire.type, - sc->status.acquire.mode, - sc->status.acquire.averages); - - send_text(s, "Horizontal: Mode: %s, Offset: %lg, Delayed Offset: %lg, Scale: %lg, Format: %s
\n", - sc->status.timebase.mode, - sc->status.timebase.offset, - sc->status.timebase.delayed_offset, - sc->status.timebase.scale, - sc->status.timebase.format); - send_text(s, "Measure CH2:
\n"); send_text(s, "VPP: %lg, VMAX: %lg, VMIN: %lg, VAMPLITUDE: %lg, VTOP: %lg, VBASE: %lg, VAVERAGE: %lg, VRMS: %lg
\n", sc->status.measure.ch2.vpp, @@ -155,19 +147,14 @@ static void serve_index(int s, struct scope *sc, char *param) sc->status.measure.ch2.pdelay, sc->status.measure.ch2.ndelay); - send_text(s, "Acquire: Type: %s, Mode: %s, Averages: %d
\n", + send_text(s, "
Acquire: Type: %s, Mode: %s, Averages: %d, CH1: %.10lg samples/s, CH2: %.10lg samples/s
\n", sc->status.acquire.type, sc->status.acquire.mode, - sc->status.acquire.averages); - - send_text(s, "Horizontal: Mode: %s, Offset: %lg, Delayed Offset: %lg, Scale: %lg, Format: %s

\n", - sc->status.timebase.mode, - sc->status.timebase.offset, - sc->status.timebase.delayed_offset, - sc->status.timebase.scale, - sc->status.timebase.format); + sc->status.acquire.averages, + sc->status.acquire.srate_ch1, + sc->status.acquire.srate_ch2); - send_text(s, "Display: Type: %s, Grid: %s, Persist: %d, MNUDisplay: %s, MNUStatus: %d, Screen: %s, Brightness: %d, Intensity: %d

\n", + send_text(s, "
Display: Type: %s, Grid: %s, Persist: %d, MNUDisplay: %s, MNUStatus: %d, Screen: %s, Brightness: %d, Intensity: %d

\n", sc->status.display.type, sc->status.display.grid, sc->status.display.persist, @@ -176,21 +163,35 @@ static void serve_index(int s, struct scope *sc, char *param) sc->status.display.screen, sc->status.display.brightness, sc->status.display.intensity); + + for (i = 1; i <= 2; i++) { + if (i == 1) { + ch = &(sc->status.channel.ch1); + } else { + ch = &(sc->status.channel.ch2); + } + send_text(s, "Channel %d: ", i); + + send_text(s, "BWLimit: %d, Coupling: %s, Displayed: %d, Inverted: %d, Offset: %lg, Probe: %lgX, Scale: %lg, Filter: %d, Memory Depth: %d, Vernier: %s
\n", + ch->bwlimit_enabled, + ch->coupling, + ch->displayed, + ch->inverted, + ch->offset, + ch->probe, + ch->scale, + ch->filter_enabled, + ch->memory_depth, + ch->vernier); + } - send_text(s, "Channel 1: "); - send_command_output(s, sc, ":CHAN1:DISP?"); - send_text(s, ", "); - send_command_output(s, sc, ":CHAN1:MEMD?"); - send_text(s, " sample depth, %.10lg samples/s
\n", sc->status.acquire.srate_ch1); - send_text(s, "Channel 2: "); - send_command_output(s, sc, ":CHAN2:DISP?"); - send_text(s, ", "); - send_command_output(s, sc, ":CHAN2:MEMD?"); - send_text(s, " sample depth, %.10lg samples/s
\n", sc->status.acquire.srate_ch2); - - releasescope(sc); + send_text(s, "
Horizontal: Mode: %s, Offset: %lg, Delayed Offset: %lg, Scale: %lg, Format: %s
\n", + sc->status.timebase.mode, + sc->status.timebase.offset, + sc->status.timebase.delayed_offset, + sc->status.timebase.scale, + sc->status.timebase.format); - send_text(s, sc->status.system.lang); send_text(s, "
\n"); send_text(s, "
\n"); diff --git a/scope.c b/scope.c index 6013893..9b75ba4 100644 --- a/scope.c +++ b/scope.c @@ -198,6 +198,37 @@ void update_scope_measurements(struct scope *sc) } +void update_scope_channel(struct scope *sc, int channel) +{ + struct channel_s *ch; + char cmd[128]; + int offs; + + if (channel == 1) { + ch = &(sc->status.channel.ch1); + strcpy(cmd, ":CHAN1:"); + } else if (channel == 2) { + ch = &(sc->status.channel.ch2); + strcpy(cmd, ":CHAN2:"); + } else { + fprintf(stderr, "Unknown channel %d!\n", channel); + return; + } + + offs=strlen(cmd); + + strcpy(cmd + offs, "BWL?"); ch->bwlimit_enabled = scope_get_truth_value(sc, cmd); + strcpy(cmd + offs, "COUP?"); COPY_SCOPE_STRING(sc, cmd, ch->coupling); + strcpy(cmd + offs, "DISP?"); ch->displayed = scope_get_truth_value(sc, cmd); + strcpy(cmd + offs, "INV?"); ch->inverted = scope_get_truth_value(sc, cmd); + strcpy(cmd + offs, "OFFS?"); ch->offset = scope_get_double(sc, cmd); + strcpy(cmd + offs, "PROB?"); ch->probe = scope_get_double(sc, cmd); + strcpy(cmd + offs, "SCAL?"); ch->scale = scope_get_double(sc, cmd); + strcpy(cmd + offs, "FILT?"); ch->filter_enabled = scope_get_truth_value(sc, cmd); + strcpy(cmd + offs, "MEMD?"); ch->memory_depth = scope_get_int(sc, cmd); + strcpy(cmd + offs, "VERN?"); COPY_SCOPE_STRING(sc, cmd, ch->vernier); +} + int update_scope_status(struct scope *sc) { bzero(&(sc->status), sizeof(sc->status)); @@ -220,6 +251,9 @@ int update_scope_status(struct scope *sc) sc->status.display.brightness = scope_get_int(sc, ":DISP:BRIG?"); sc->status.display.intensity = scope_get_int(sc, ":DISP:INT?"); + update_scope_channel(sc, 1); + update_scope_channel(sc, 2); + COPY_SCOPE_STRING(sc, ":ACQ:TYPE?", sc->status.acquire.type); COPY_SCOPE_STRING(sc, ":ACQ:MODE?", sc->status.acquire.mode); diff --git a/scope.h b/scope.h index 86ce9df..453aaf6 100644 --- a/scope.h +++ b/scope.h @@ -26,7 +26,16 @@ struct measure_s { }; struct channel_s { - /* TODO */ + int bwlimit_enabled; + char coupling[32]; + int displayed; + int inverted; + double offset; + double probe; + double scale; + int filter_enabled; + int memory_depth; + char vernier[32]; }; struct scope { -- 2.39.5