/* ************************************************************** */ /* * Module BTWIREUI * This module contains functions for the BTWIRE user interface. * * Zachary Wolf * 6/6/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include #include "btwireuir.h" #include "btwireui.h" #include "btwire.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct btwire_param_struct btwire_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int btwire_panel; static int btwire_v_panel; static int btwireop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void btwireui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * btwireui_init * This function initializes the user interface for the Btwire system. * * Input: * top_pos, vertical position of top left panel corner in screen coordinates * left_pos, horizontal position of top left panel corner in screen coordinates * btwire_par, btwire system parameters * * Zachary Wolf * 6/6/02 */ void btwireui_init(int top_pos, int left_pos, struct btwire_param_struct btwire_param_in) { /* Save parameters for future use */ btwire_param = btwire_param_in; /* Make sure the user interface panel is desired */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Open the Btwire panels */ btwire_v_panel = LoadPanel(0, "btwireuir.uir", BTWIREVPAN); if (btwire_v_panel < 0) { btwireui_error("Could not open user interface panel"); return; } btwire_panel = LoadPanel(0, "btwireuir.uir", BTWIREPAN); if (btwire_panel < 0) { btwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(btwire_v_panel, top_pos, left_pos); SetPanelPos(btwire_panel, top_pos, left_pos + 325 + 10); /* Display the panel */ DisplayPanel(btwire_v_panel); DisplayPanel(btwire_panel); /* Done */ return; } /* ************************************************************** */ /* * btwireopui_init * This function initializes the user interface for the Btwire system. * * Input: * top_pos, vertical position of top left panel corner in screen coordinates * left_pos, horizontal position of top left panel corner in screen coordinates * * Zachary Wolf * 6/6/02 */ void btwireopui_init(int top_pos, int left_pos) { /* Open the Btwireop panel */ btwireop_panel = LoadPanel(0, "btwireuir.uir", BTOPPAN); if (btwireop_panel < 0) { btwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(btwireop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(btwireop_panel); /* Done */ return; } /* ************************************************************** */ /* * btwireui_update_v_vs_t * This function adds measured points to the Vx, Vy vs T plot. * * Input: * num_samp, number of samples in the waveform * t[0 to num_samp - 1], time of each sample relative to the trigger (sec) * v_w_x[0 to num_samp - 1], voltage samples from the wire x-position sensor (V) * v_w_y[0 to num_samp - 1], voltage samples from the wire y-position sensor (V) * * Zachary Wolf * 6/6/02 */ void btwireui_update_v_vs_t(int num_samp, double t[], double v_w_x[], double v_w_y[]) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Plot the Vx, Vy samples */ PlotXY(btwire_v_panel, BTWIREVPAN_GRAPH_V_VS_T, t, v_w_x, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); PlotXY(btwire_v_panel, BTWIREVPAN_GRAPH_V_VS_T, t, v_w_y, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ /* * btwireui_mark_calib_magnet_v_vs_t * This function marks the calibration magnet in the Vx, Vy vs T plots. * * Input: * t, time of the sample corresponding to the callibration magnet (sec) * v, voltage sample from the wire position sensor (V) * * Zachary Wolf * 6/6/02 */ void btwireui_mark_calib_magnet_v_vs_t(double t, double v) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Plot the sample */ PlotPoint (btwire_v_panel, BTWIREVPAN_GRAPH_V_VS_T, t, v, VAL_SOLID_SQUARE, VAL_BLACK); /* Done */ return; } /* ************************************************************** */ /* * btwireui_clear_v_vs_t * This function clears the V vs T plot. * * Zachary Wolf * 6/6/02 */ void btwireui_clear_v_vs_t(void) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(btwire_v_panel, BTWIREVPAN_GRAPH_V_VS_T, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* * btwireui_update_dvdt_vs_t * This function adds measured points to the dVx/dt, dVy/dt vs T plot. * * Input: * num_samp, number of samples in the waveform * t[0 to num_samp - 1], time of each sample relative to the trigger (sec) * dvdt_w_x[0 to num_samp - 1], voltage derivative samples from the wire x-position sensor (V/s) * dvdt_w_y[0 to num_samp - 1], voltage derivative samples from the wire y-position sensor (V/s) * * Zachary Wolf * 6/6/02 */ void btwireui_update_dvdt_vs_t(int num_samp, double t[], double dvdt_w_x[], double dvdt_w_y[]) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Plot the dVx/dt, dVy/dt samples */ PlotXY(btwire_v_panel, BTWIREVPAN_GRAPH_DVDT_VS_T, t, dvdt_w_x, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); PlotXY(btwire_v_panel, BTWIREVPAN_GRAPH_DVDT_VS_T, t, dvdt_w_y, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ /* * btwireui_mark_calib_magnet_dvdt_vs_t * This function marks the calibration magnet in the dVx/dt, dVy/dt vs T plots. * * Input: * t, time of the sample corresponding to the callibration magnet (sec) * dvdt, voltage time derivative sample from the wire position sensor (V) * * Zachary Wolf * 6/6/02 */ void btwireui_mark_calib_magnet_dvdt_vs_t(double t, double dvdt) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Plot the sample */ PlotPoint (btwire_v_panel, BTWIREVPAN_GRAPH_DVDT_VS_T, t, dvdt, VAL_SOLID_SQUARE, VAL_BLACK); /* Done */ return; } /* ************************************************************** */ /* * btwireui_clear_dvdt_vs_t * This function clears the dV/dt vs T plot. * * Zachary Wolf * 6/6/02 */ void btwireui_clear_dvdt_vs_t(void) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(btwire_v_panel, BTWIREVPAN_GRAPH_DVDT_VS_T, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* * btwireui_update_bt_vs_z * This function adds measured points to the Bx, By vs Z plots. * * Input: * num_samp, number of samples in the waveform * z[0 to num_samp - 1], z position of each sample relative to the wire position detectors (m) * b_x[0 to num_samp - 1], x component of the transverse field along the wire (T) * b_y[0 to num_samp - 1], y component of the transverse field along the wire (T) * * Zachary Wolf * 6/6/02 */ void btwireui_update_bt_vs_z(int num_samp, double z[], double b_x[], double b_y[]) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Plot the Bx, By samples */ PlotXY(btwire_panel, BTWIREPAN_GRAPH_BX_VS_Z, z, b_x, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_BLUE); PlotXY(btwire_panel, BTWIREPAN_GRAPH_BY_VS_Z, z, b_y, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); /* Done */ return; } /* ************************************************************** */ /* * btwireui_mark_calib_magnet_bt_vs_z * This function marks the calibration magnet in the Bx, By vs Z plots. * * Input: * z, z position of the callibration magnet (m) * b_x, Bx of the calibration magnet (T) * b_y, By of the calibration magnet (T) * * Zachary Wolf * 6/6/02 */ void btwireui_mark_calib_magnet_bt_vs_z(double z_x, double b_x, double z_y, double b_y) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Plot the samples */ PlotPoint (btwire_panel, BTWIREPAN_GRAPH_BX_VS_Z, z_x, b_x, VAL_SOLID_SQUARE, VAL_BLACK); PlotPoint (btwire_panel, BTWIREPAN_GRAPH_BY_VS_Z, z_y, b_y, VAL_SOLID_SQUARE, VAL_BLACK); /* Done */ return; } /* ************************************************************** */ /* * btwireui_clear_bt_vs_z * This function clears the Bt vs Z plot. * * Zachary Wolf * 6/6/02 */ void btwireui_clear_bt_vs_z(void) { /* Check for the user interface */ if (btwire_param.show_ui != BTWIRE_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(btwire_panel, BTWIREPAN_GRAPH_BX_VS_Z, -1, VAL_IMMEDIATE_DRAW); DeleteGraphPlot(btwire_panel, BTWIREPAN_GRAPH_BY_VS_Z, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * btwireui_error * This function handles error messages for the BLwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 9/18/98 */ void btwireui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nBTWIREUI ERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press ENTER to continue.\nPress any key then ENTER to terminate program.\n"); fgets(buf, 80, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* CALLBACK FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK btwireopui_meas (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { /* Declare all variables */ long int num_samp; double z[BTWIRE_MAX_NUM_SAMP]; double b_x[BTWIRE_MAX_NUM_SAMP]; double b_y[BTWIRE_MAX_NUM_SAMP]; switch (event) { case EVENT_COMMIT: /* Perform a measurement */ btwire_get_bt_vs_z('y', &num_samp, z, b_x, b_y); break; } return 0; } /* ************************************************************** */ int CVICALLBACK btwireopui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: QuitUserInterface(0); break; } return 0; }