]> git.zerfleddert.de Git - rigol/commitdiff
add measurements to web if
authorMichael Gernoth <michael@gernoth.net>
Fri, 11 Jun 2010 20:20:41 +0000 (22:20 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 11 Jun 2010 20:20:41 +0000 (22:20 +0200)
rigold.c
scope.c
scope.h

index 29712e07b09db7230dc510be3032b9554c0d5a80..e97db7c2fd7510b012c074293d858976d44be99d 100644 (file)
--- a/rigold.c
+++ b/rigold.c
@@ -69,13 +69,48 @@ static void serve_index(int s, struct scope *sc, char *param)
        claimscope(sc);
        update_scope_status(sc);
 
-       send_text(s, "System: Language: %s, Counter: %d, Beep: %d<br>\n",
+       send_text(s, "System: Language: %s, Counter: %d, Beep: %d<br><br>\n",
                sc->status.system.lang,
                sc->status.system.counter_enabled,
                sc->status.system.beep_enabled);
        
-       send_text(s, "Keyboard: Key Lock: %d<br>\n",
+       send_text(s, "Keyboard: Key Lock: %d<br><br>\n",
                sc->status.keyboard.key_lock);
+       
+       send_text(s, "Measure: Source: %s, Total: %d<br>\n",
+               sc->status.measure.source,
+               sc->status.measure.total);
+
+       send_text(s, "Measure CH1:<br>\n");
+       send_text(s, "VPP: %lg, VMAX: %lg, VMIN: %lg, VAMPLITUDE: %lg, VTOP: %lg, VBASE: %lg, VAVERAGE: %lg, VRMS: %lg<br>\n",
+               sc->status.measure.ch1.vpp,
+               sc->status.measure.ch1.vmax,
+               sc->status.measure.ch1.vmin,
+               sc->status.measure.ch1.vamplitude,
+               sc->status.measure.ch1.vtop,
+               sc->status.measure.ch1.vbase,
+               sc->status.measure.ch1.vaverage,
+               sc->status.measure.ch1.vrms);
+       
+       send_text(s, "Overshoot: %lg, Preshoot: %lg<br>\n",
+               sc->status.measure.ch1.overshoot,
+               sc->status.measure.ch1.preshoot);
+
+       send_text(s, "Frequency: %lg, Risetime: %lg, Falltime: %lg<br>\n",
+               sc->status.measure.ch1.frequency,
+               sc->status.measure.ch1.risetime,
+               sc->status.measure.ch1.falltime);
+
+       send_text(s, "Period: %lg, Pwidth: %lg, Nwidth: %lg, Pdutycycle: %lg, Ndutycycle: %lg<br>\n",
+               sc->status.measure.ch1.period,
+               sc->status.measure.ch1.pwidth,
+               sc->status.measure.ch1.nwidth,
+               sc->status.measure.ch1.pdutycycle,
+               sc->status.measure.ch1.ndutycycle);
+
+       send_text(s, "Pdelay: %lg, Ndelay: %lg<br>\n",
+               sc->status.measure.ch1.pdelay,
+               sc->status.measure.ch1.ndelay);
 
        send_text(s, "Acquire: Type: %s, Mode: %s, Averages: %d<br>\n",
                sc->status.acquire.type,
@@ -89,32 +124,69 @@ static void serve_index(int s, struct scope *sc, char *param)
                sc->status.timebase.scale,
                sc->status.timebase.format);
 
-       send_text(s, "Display: ");
-       send_command_output(s, sc, ":DISP:TYPE?");
-       send_text(s, ", ");
-       send_command_output(s, sc, ":DISP:SCR?");
-       send_text(s, ", Grid: ");
-       send_command_output(s, sc, ":DISP:GRID?");
-       send_text(s, ", Persistence: ");
-       send_command_output(s, sc, ":DISP:PERS?");
-       send_text(s, ", Menu: ");
-       send_command_output(s, sc, ":DISP:MNUS?");
-       send_text(s, ", Brightness: ");
-       send_command_output(s, sc, ":DISP:BRIG?");
-       send_text(s, ", Intensity: ");
-       send_command_output(s, sc, ":DISP:INT?");
-       send_text(s, "<br>\n");
+       send_text(s, "Measure CH2:<br>\n");
+       send_text(s, "VPP: %lg, VMAX: %lg, VMIN: %lg, VAMPLITUDE: %lg, VTOP: %lg, VBASE: %lg, VAVERAGE: %lg, VRMS: %lg<br>\n",
+               sc->status.measure.ch2.vpp,
+               sc->status.measure.ch2.vmax,
+               sc->status.measure.ch2.vmin,
+               sc->status.measure.ch2.vamplitude,
+               sc->status.measure.ch2.vtop,
+               sc->status.measure.ch2.vbase,
+               sc->status.measure.ch2.vaverage,
+               sc->status.measure.ch2.vrms);
+       
+       send_text(s, "Overshoot: %lg, Preshoot: %lg<br>\n",
+               sc->status.measure.ch2.overshoot,
+               sc->status.measure.ch2.preshoot);
+
+       send_text(s, "Frequency: %lg, Risetime: %lg, Falltime: %lg<br>\n",
+               sc->status.measure.ch2.frequency,
+               sc->status.measure.ch2.risetime,
+               sc->status.measure.ch2.falltime);
+
+       send_text(s, "Period: %lg, Pwidth: %lg, Nwidth: %lg, Pdutycycle: %lg, Ndutycycle: %lg<br>\n",
+               sc->status.measure.ch2.period,
+               sc->status.measure.ch2.pwidth,
+               sc->status.measure.ch2.nwidth,
+               sc->status.measure.ch2.pdutycycle,
+               sc->status.measure.ch2.ndutycycle);
+
+       send_text(s, "Pdelay: %lg, Ndelay: %lg<br>\n",
+               sc->status.measure.ch2.pdelay,
+               sc->status.measure.ch2.ndelay);
+
+       send_text(s, "Acquire: Type: %s, Mode: %s, Averages: %d<br>\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<br><br>\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, "Display: Type: %s, Grid: %s, Persist: %d, MNUDisplay: %s, MNUStatus: %d, Screen: %s, Brightnbess: %d, Intensity: %d<br><br>\n",
+               sc->status.display.type,
+               sc->status.display.grid,
+               sc->status.display.persist,
+               sc->status.display.mnudisplay,
+               sc->status.display.mnustatus,
+               sc->status.display.screen,
+               sc->status.display.brightness,
+               sc->status.display.intensity);
 
        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<br>\n", sc->status.acquire.srate_chan1);
+       send_text(s, " sample depth, %.10lg samples/s<br>\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<br>\n", sc->status.acquire.srate_chan2);
+       send_text(s, " sample depth, %.10lg samples/s<br>\n", sc->status.acquire.srate_ch2);
 
        releasescope(sc);
 
diff --git a/scope.c b/scope.c
index eab7750c64c76fa8dd3dbb76354f2a8d03e74d64..6013893107b34b609c2d3a87351a1fd3096bc197 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -149,6 +149,55 @@ double scope_get_double(struct scope *sc, char*cmd)
        return ret;
 }
 
+void update_scope_measurements(struct scope *sc)
+{
+       sc->status.measure.ch1.vpp = scope_get_double(sc, ":MEAS:VPP? CHAN1");
+       sc->status.measure.ch1.vmax = scope_get_double(sc, ":MEAS:VMAX? CHAN1");
+       sc->status.measure.ch1.vmin = scope_get_double(sc, ":MEAS:VMIN? CHAN1");
+       sc->status.measure.ch1.vamplitude = scope_get_double(sc, ":MEAS:VAMP? CHAN1");
+       sc->status.measure.ch1.vtop = scope_get_double(sc, ":MEAS:VTOP? CHAN1");
+       sc->status.measure.ch1.vbase = scope_get_double(sc, ":MEAS:VBAS? CHAN1");
+       sc->status.measure.ch1.vaverage = scope_get_double(sc, ":MEAS:VAV? CHAN1");
+       sc->status.measure.ch1.vrms = scope_get_double(sc, ":MEAS:VRMS? CHAN1");
+       sc->status.measure.ch1.overshoot = scope_get_double(sc, ":MEAS:OVER? CHAN1");
+       sc->status.measure.ch1.preshoot = scope_get_double(sc, ":MEAS:PRES? CHAN1");
+       sc->status.measure.ch1.frequency = scope_get_double(sc, ":MEAS:FREQ? CHAN1");
+       sc->status.measure.ch1.risetime = scope_get_double(sc, ":MEAS:RIS? CHAN1");
+       sc->status.measure.ch1.falltime = scope_get_double(sc, ":MEAS:FALL? CHAN1");
+       sc->status.measure.ch1.period = scope_get_double(sc, ":MEAS:PER? CHAN1");
+       sc->status.measure.ch1.pwidth = scope_get_double(sc, ":MEAS:PWID? CHAN1");
+       sc->status.measure.ch1.nwidth = scope_get_double(sc, ":MEAS:NWID? CHAN1");
+       sc->status.measure.ch1.pdutycycle = scope_get_double(sc, ":MEAS:PDUT? CHAN1");
+       sc->status.measure.ch1.ndutycycle = scope_get_double(sc, ":MEAS:NDUT? CHAN1");
+       sc->status.measure.ch1.pdelay = scope_get_double(sc, ":MEAS:PDEL? CHAN1");
+       sc->status.measure.ch1.ndelay = scope_get_double(sc, ":MEAS:NDEL? CHAN1");
+
+       sc->status.measure.ch2.vpp = scope_get_double(sc, ":MEAS:VPP? CHAN2");
+       sc->status.measure.ch2.vmax = scope_get_double(sc, ":MEAS:VMAX? CHAN2");
+       sc->status.measure.ch2.vmin = scope_get_double(sc, ":MEAS:VMIN? CHAN2");
+       sc->status.measure.ch2.vamplitude = scope_get_double(sc, ":MEAS:VAMP? CHAN2");
+       sc->status.measure.ch2.vtop = scope_get_double(sc, ":MEAS:VTOP? CHAN2");
+       sc->status.measure.ch2.vbase = scope_get_double(sc, ":MEAS:VBAS? CHAN2");
+       sc->status.measure.ch2.vaverage = scope_get_double(sc, ":MEAS:VAV? CHAN2");
+       sc->status.measure.ch2.vrms = scope_get_double(sc, ":MEAS:VRMS? CHAN2");
+       sc->status.measure.ch2.overshoot = scope_get_double(sc, ":MEAS:OVER? CHAN2");
+       sc->status.measure.ch2.preshoot = scope_get_double(sc, ":MEAS:PRES? CHAN2");
+       sc->status.measure.ch2.frequency = scope_get_double(sc, ":MEAS:FREQ? CHAN2");
+       sc->status.measure.ch2.risetime = scope_get_double(sc, ":MEAS:RIS? CHAN2");
+       sc->status.measure.ch2.falltime = scope_get_double(sc, ":MEAS:FALL? CHAN2");
+       sc->status.measure.ch2.period = scope_get_double(sc, ":MEAS:PER? CHAN2");
+       sc->status.measure.ch2.pwidth = scope_get_double(sc, ":MEAS:PWID? CHAN2");
+       sc->status.measure.ch2.nwidth = scope_get_double(sc, ":MEAS:NWID? CHAN2");
+       sc->status.measure.ch2.pdutycycle = scope_get_double(sc, ":MEAS:PDUT? CHAN2");
+       sc->status.measure.ch2.ndutycycle = scope_get_double(sc, ":MEAS:NDUT? CHAN2");
+       sc->status.measure.ch2.pdelay = scope_get_double(sc, ":MEAS:PDEL? CHAN2");
+       sc->status.measure.ch2.ndelay = scope_get_double(sc, ":MEAS:NDEL? CHAN2");
+
+       sc->status.measure.total = scope_get_truth_value(sc, ":MEAS:TOT?");
+       COPY_SCOPE_STRING(sc, ":MEAS:SOUR?", sc->status.measure.source);
+
+}
+
 int update_scope_status(struct scope *sc)
 {
        bzero(&(sc->status), sizeof(sc->status));
@@ -160,12 +209,23 @@ int update_scope_status(struct scope *sc)
 
        sc->status.keyboard.key_lock = scope_get_truth_value(sc, ":KEY:LOCK?");
 
+       update_scope_measurements(sc);
+
+       COPY_SCOPE_STRING(sc, ":DISP:TYPE?", sc->status.display.type);
+       COPY_SCOPE_STRING(sc, ":DISP:GRID?", sc->status.display.grid);
+       sc->status.display.persist = scope_get_truth_value(sc, ":DISP:PERS?");
+       COPY_SCOPE_STRING(sc, ":DISP:MNUD?", sc->status.display.mnudisplay);
+       sc->status.display.mnustatus = scope_get_truth_value(sc, ":DISP:MNUS?");
+       COPY_SCOPE_STRING(sc, ":DISP:SCR?", sc->status.display.screen);
+       sc->status.display.brightness = scope_get_int(sc, ":DISP:BRIG?");
+       sc->status.display.intensity = scope_get_int(sc, ":DISP:INT?");
+
        COPY_SCOPE_STRING(sc, ":ACQ:TYPE?", sc->status.acquire.type);
        COPY_SCOPE_STRING(sc, ":ACQ:MODE?", sc->status.acquire.mode);
 
        sc->status.acquire.averages = scope_get_int(sc, ":ACQ:AVER?");
-       sc->status.acquire.srate_chan1 = scope_get_double(sc, ":ACQ:SAMP? CHAN1");
-       sc->status.acquire.srate_chan2 = scope_get_double(sc, ":ACQ:SAMP? CHAN2");
+       sc->status.acquire.srate_ch1 = scope_get_double(sc, ":ACQ:SAMP? CHAN1");
+       sc->status.acquire.srate_ch2 = scope_get_double(sc, ":ACQ:SAMP? CHAN2");
        sc->status.acquire.srate_digital = scope_get_double(sc, ":ACQ:SAMP? DIGITAL");
 
        COPY_SCOPE_STRING(sc, ":TIM:MODE?", sc->status.timebase.mode);
diff --git a/scope.h b/scope.h
index cef5e650e4c5125527b410b046ba80d714f13817..86ce9df009d67399d1f53fa179b43d9496e7d687 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -1,3 +1,34 @@
+struct measure_s {
+       double vpp;
+       double vmax;
+       double vmin;
+       double vamplitude;
+       double vtop;
+       double vbase;
+       double vaverage;
+       double vrms;
+
+       double overshoot;
+       double preshoot;
+
+       double frequency;
+       double risetime;
+       double falltime;
+
+       double period;
+       double pwidth;
+       double nwidth;
+       double pdutycycle;
+       double ndutycycle;
+
+       double pdelay;
+       double ndelay;
+};
+
+struct channel_s {
+       /* TODO */
+};
+
 struct scope {
        struct {
                struct usb_dev_handle *dev;
@@ -20,24 +51,36 @@ struct scope {
                } keyboard;
 
                struct {
-                       /* TODO */
+                       struct measure_s ch1;
+                       struct measure_s ch2;
+
+                       int total;
+                       char source[32];
                } measure;
 
                struct {
                        char type[32];
                        char mode[32];
                        int averages;
-                       double srate_chan1;
-                       double srate_chan2;
+                       double srate_ch1;
+                       double srate_ch2;
                        double srate_digital;
                } acquire;
 
                struct {
-                       /* TODO */
+                       char type[32];
+                       char grid[32];
+                       int persist;
+                       char mnudisplay[32];
+                       int mnustatus;
+                       char screen[32];
+                       int brightness;
+                       int intensity;
                } display;
 
                struct {
-                       /* TODO */
+                       struct channel_s ch1;
+                       struct channel_s ch2;
                } channel;
 
                struct {
@@ -74,4 +117,5 @@ char *scope_get_string(struct scope *sc, char *cmd, int maxlen);
 int scope_get_truth_value(struct scope *sc, char *cmd);
 int scope_get_int(struct scope *sc, char *cmd);
 double scope_get_double(struct scope *sc, char*cmd);
+void update_scope_measurements(struct scope *sc);
 int update_scope_status(struct scope *sc);
Impressum, Datenschutz