/* ************************************************************** */ /* * Module VIBRATINGWIREUI * This module contains functions for the vibrating wire system * user interface. * * Zachary Wolf * 10/6/05 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vibrating wire uir.h" #include "vibrating wire ui.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vibratingwire_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vibratingwireui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vibratingwireui_init * This function initializes the user interface for the vibrating wire 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 * 10/6/05 */ void vibratingwireui_init(int top_pos, int left_pos) { /* Open the panel */ vibratingwire_panel = LoadPanel(0, "vibrating wire uir.uir", VWPAN); if (vibratingwire_panel < 0) { vibratingwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vibratingwire_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vibratingwire_panel); /* Done */ return; } /* ************************************************************** */ /* * vibratingwireui_scale_horiz_axis * This function sets the scale on the horizontal axis of the * lock-in voltage vs position graph. * * Input: * num_x_pos, number of x positions * x_pos[0 to num_x_pos - 1], x positions * * Zachary Wolf * 10/6/05 * Modified by Michael Levashov 07/24/07 */ void vibratingwireui_scale_horiz_axis(int num_x_pos, double x_step, double x_center) { /* Declare variables */ double x_min, x_max; /* Determine the minimum and maximum x positions */ //MaxMin1D(x_pos, num_x_pos, &x_max, &max_index, &x_min, &min_index); x_min = x_center - x_step*(num_x_pos - 1.)/2. - .1 * (num_x_pos - 1) * x_step; x_max = x_center + x_step*(num_x_pos - 1.)/2. + .1 * (num_x_pos - 1) * x_step; /* Set the horizontal scale of the plot */ SetAxisRange(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, VAL_MANUAL, x_min, x_max, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ void vibratingwireui_write_title(char title[]) { /* Write the title */ SetCtrlVal(vibratingwire_panel, VWPAN_STR_TITLE, title); /* Done */ return; } /* ************************************************************** */ void vibratingwireui_update_meas(double pos, double xdet_vxrms, double xdet_vyrms, double ydet_vxrms, double ydet_vyrms) { /* Plot the measured values */ PlotPoint(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, pos, xdet_vxrms, VAL_SOLID_CIRCLE, VAL_GREEN); PlotPoint(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, pos, xdet_vyrms, VAL_SOLID_CIRCLE, VAL_RED); PlotPoint(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, pos, ydet_vxrms, VAL_SOLID_CIRCLE, VAL_CYAN); PlotPoint(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, pos, ydet_vyrms, VAL_SOLID_CIRCLE, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ void vibratingwireui_plot_center_fit(int num_fit, double fit_x[], double fit_y[], double zero_pos) { /* Plot the linear fit results */ PlotLine (vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, fit_x[0], fit_y[0], fit_x[num_fit - 1], fit_y[num_fit - 1], VAL_DK_RED); /* Plot the magnet position when centered */ PlotPoint(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, zero_pos, 0., VAL_SOLID_SQUARE, VAL_DK_RED); /* Done */ return; } /* ************************************************************** */ void vibratingwireui_clear_plot(void) { /* Remove previous plot */ DeleteGraphPlot(vibratingwire_panel, VWPAN_GRAPH_V_VS_POS, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vibratingwireui_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 vibratingwireui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVIBRATINGWIREUI 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); }