/* ************************************************************** */ /* * Module BLWIREUI * This module contains functions for the integrated field * strength measurement user interface. * * Zachary Wolf * 12/9/99 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include #include "blwireuir.h" #include "blwireui.h" #include "blwire.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct blwire_param_struct blwire_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int blwire_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void blwireui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * blwireui_init * This function initializes the user interface for the BLwire 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 * blwire_par, blwire system parameters * * Zachary Wolf * 12/9/99 */ void blwireui_init(int top_pos, int left_pos, struct blwire_param_struct blwire_param_in) { /* Save parameters for future use */ blwire_param = blwire_param_in; /* Make sure the user interface panel is desired */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Open the BLwire panel */ blwire_panel = LoadPanel(0, "blwireuir.uir", BLWIREPAN); if (blwire_panel < 0) { blwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(blwire_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(blwire_panel); /* Done */ return; } /* ************************************************************** */ /* * blwireui_scale_bl_vs_x * This function sets the scale on the horizontal axis of the BL vs X * plot. * * Input: * num_x_pos, number of x positions * x_pos[0 to num_x_pos - 1], x positions * * Zachary Wolf * 2/14/00 */ void blwireui_scale_bl_vs_x(int num_x_pos, double x_pos[]) { /* Declare variables */ double x_min, x_max; int min_index, max_index; /* Make sure the user interface panel is being used */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Determine the minimum and maximum x positions */ MaxMin1D(x_pos, num_x_pos, &x_max, &max_index, &x_min, &min_index); x_min = x_min - .01; x_max = x_max + .01; /* Set the horizontal scale of the BL vs X plot */ SetAxisRange(blwire_panel, BLWIREPAN_GRAPH_BL_VS_X, VAL_MANUAL, x_min, x_max, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ /* * blwireui_update_bl_vs_x * This function adds measured points to the BL vs X plot. * * Input: * x0, x position of the measurement (m) * bl_ave, average of the integrated field strength measurements (Tm) * bl_rms, rms variation of the integrated field strength measurements (Tm) * * Zachary Wolf * 2/14/00 */ void blwireui_update_bl_vs_x(double x0, double bl_ave, double bl_rms) { /* Check for the user interface */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Plot the BL sample */ PlotPoint(blwire_panel, BLWIREPAN_GRAPH_BL_VS_X, x0, bl_ave, VAL_SOLID_SQUARE, VAL_RED); /* Done */ return; } /* ************************************************************** */ /* * blwireui_update_bl_vs_x_fit * This function adds fitted points to the BL vs X plot. * * Input: * num_x0_pos, number of x positions * x0[0 to num_x0_pos - 1], x positions (m) * bl_fit[0 to num_x0_pos - 1], fitted integrated field strength at each x position (Tm) * * Zachary Wolf * 2/14/00 */ void blwireui_update_bl_vs_x_fit(int num_x0_pos, double x0[], double bl_fit[]) { /* Check for the user interface */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Plot the BL samples */ PlotXY(blwire_panel, BLWIREPAN_GRAPH_BL_VS_X, x0, bl_fit, num_x0_pos, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ /* * blwireui_clear_bl_vs_x * This function clears the BL vs X plot. * * Zachary Wolf * 2/14/00 */ void blwireui_clear_bl_vs_x(void) { /* Check for the user interface */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(blwire_panel, BLWIREPAN_GRAPH_BL_VS_X, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* * blwireui_scale_str_vs_imag * This function sets the scale on the horizontal axis of the strength * vs Imag plot. * * Input: * num_imag, number of magnet currents * imag[0 to num_imag - 1], magnet currents * * Zachary Wolf * 2/14/00 */ void blwireui_scale_str_vs_imag(int num_imag, double imag[]) { /* Declare variables */ double i_min, i_max; int min_index, max_index; double i_min_plt, i_max_plt; /* Make sure the user interface panel is being used */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Determine the minimum and maximum magnet currents */ MaxMin1D(imag, num_imag, &i_max, &max_index, &i_min, &min_index); i_min_plt = i_min - .01 * (i_max - i_min) - 1.; i_max_plt = i_max + .01 * (i_max - i_min) + 1.; i_min_plt = floor(i_min_plt); i_max_plt = ceil(i_max_plt); /* Set the horizontal scale of the BL vs X plot */ SetAxisRange(blwire_panel, BLWIREPAN_GRAPH_STR_VS_I, VAL_MANUAL, i_min_plt, i_max_plt, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ /* * blwireui_update_str_vs_imag * This function adds measured points to the strength vs Imag plot. * * Input: * imag, magnet current (A) * str_ave, average of the magnet strength measurements (Tm/m^(n-1)) * str_rms, rms variation of the magnet strength measurements (Tm/m^(n-1)) * * Zachary Wolf * 2/14/00 */ void blwireui_update_str_vs_imag(double imag, double str_ave, double str_rms) { /* Check for the user interface */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Plot the magnet strength sample */ PlotPoint(blwire_panel, BLWIREPAN_GRAPH_STR_VS_I, imag, str_ave, VAL_SOLID_SQUARE, VAL_RED); /* Done */ return; } /* ************************************************************** */ /* * blwireui_clear_str_vs_imag * This function clears the strength vs Imag plot. * * Zachary Wolf * 2/14/00 */ void blwireui_clear_str_vs_imag(void) { /* Check for the user interface */ if (blwire_param.show_ui != BLWIRE_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(blwire_panel, BLWIREPAN_GRAPH_STR_VS_I, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * blwireui_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 blwireui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nBLWIREUI 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); }