/* ************************************************************** */ /* * Module VIBWIREUI * This module contains functions for the vibrating wire * system user interface. * * Zachary Wolf * 8/29/05 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vibwireuir.h" #include "vibwireui.h" #include "vibwire.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct vibwire_param_struct vibwire_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vibwire_panel; static int vibwireop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vibwireui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vibwireui_init * This function initializes the user interface for the VIBWIRE 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 * vibwire_par, vibwire system parameters * * Zachary Wolf * 8/29/05 */ void vibwireui_init(int top_pos, int left_pos, struct vibwire_param_struct vibwire_par) { /* Save parameters for future use */ vibwire_param = vibwire_par; /* Make sure the user interface panel is desired */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Open the vibwire panel */ vibwire_panel = LoadPanel(0, "c:\\dataccvi\\lib\\system\\vibwire\\vibwireuir.uir", VIBWIREPAN); if (vibwire_panel < 0) { vibwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vibwire_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vibwire_panel); /* Done */ return; } /* ************************************************************** */ /* * vibwireopui_init * This function initializes the user interface for the VIBWIRE 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 * 8/29/05 */ void vibwireopui_init(int top_pos, int left_pos) { /* Open the vibwireop panel */ vibwireop_panel = LoadPanel(0, "vibwireuir.uir", VIBWIREOP); if (vibwire_panel < 0) { vibwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vibwireop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(vibwireop_panel); /* Done */ return; } /* ************************************************************** */ void vibwireui_clear_vx_graph(void) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Remove previous field sample plot */ DeleteGraphPlot(vibwire_panel, VIBWIREPAN_GRAPH_VX_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ void vibwireui_clear_vy_graph(void) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Remove previous field sample plot */ DeleteGraphPlot(vibwire_panel, VIBWIREPAN_GRAPH_VY_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ void vibwireui_setup_vx_graph(double x_min, double x_max, double y_min, double y_max) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Setup the axes for the plot */ SetAxisRange(vibwire_panel, VIBWIREPAN_GRAPH_VX_SAMP, VAL_MANUAL, x_min, x_max, VAL_MANUAL, y_min, y_max); ProcessDrawEvents(); /* Done */ return; } /* ************************************************************** */ void vibwireui_setup_vy_graph(double x_min, double x_max, double y_min, double y_max) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Setup the axes for the plot */ SetAxisRange(vibwire_panel, VIBWIREPAN_GRAPH_VY_SAMP, VAL_MANUAL, x_min, x_max, VAL_MANUAL, y_min, y_max); ProcessDrawEvents(); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vx_samp(double x, double y) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the sample */ PlotPoint(vibwire_panel, VIBWIREPAN_GRAPH_VX_SAMP, x, y, VAL_SOLID_SQUARE, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vy_samp(double x, double y) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the sample */ PlotPoint(vibwire_panel, VIBWIREPAN_GRAPH_VY_SAMP, x, y, VAL_SOLID_SQUARE, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vx_res_coarse(double x, double y) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the sample */ PlotPoint(vibwire_panel, VIBWIREPAN_GRAPH_VX_SAMP, x, y, VAL_SOLID_DIAMOND, VAL_MAGENTA); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vy_res_coarse(double x, double y) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the sample */ PlotPoint(vibwire_panel, VIBWIREPAN_GRAPH_VY_SAMP, x, y, VAL_SOLID_DIAMOND, VAL_MAGENTA); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vx_res_fine(double x, double y) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the sample */ PlotPoint(vibwire_panel, VIBWIREPAN_GRAPH_VX_SAMP, x, y, VAL_SOLID_CIRCLE, VAL_RED); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vy_res_fine(double x, double y) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the sample */ PlotPoint(vibwire_panel, VIBWIREPAN_GRAPH_VY_SAMP, x, y, VAL_SOLID_CIRCLE, VAL_RED); /* Done */ return; } /* ************************************************************** */ void vibwireui_plot_vx_line(double x1, double y1, double x2, double y2) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Plot the field sample */ PlotLine(vibwire_panel, VIBWIREPAN_GRAPH_VX_SAMP, x1, y1, x2, y2, VAL_GREEN); /* Done */ return; } /* ************************************************************** */ void vibwireui_set_har_num(int har_num) { /* Check for the user interface */ if (vibwire_param.show_ui != VIBWIRE_TRUE) return; /* Display the harmonic number */ SetCtrlVal(vibwire_panel, VIBWIREPAN_NUM_HAR_NUM, har_num); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vibwireui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/29/05 */ void vibwireui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVIBWIREUI 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 vibwireuiop_set_freq (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double freq; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, VIBWIREOP_NUM_SET_FREQ, &freq); vibwire_set_freq(freq); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_set_ampl (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double ampl; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, VIBWIREOP_NUM_SET_AMPL, &l); vibwire_set_ampl(ampl); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_get_xdet_vxrms (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double vxrms; switch (event) { case EVENT_COMMIT: vibwire_get_xdet_vxrms(&vxrms); SetCtrlVal (panel, VIBWIREOP_NUM_XDET_VXRMS, vxrms); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_get_xdet_vyrms (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double vyrms; switch (event) { case EVENT_COMMIT: vibwire_get_xdet_vyrms(&vyrms); SetCtrlVal (panel, VIBWIREOP_NUM_XDET_VYRMS, vyrms); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_get_ydet_vxrms (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double vxrms; switch (event) { case EVENT_COMMIT: vibwire_get_ydet_vxrms(&vxrms); SetCtrlVal (panel, VIBWIREOP_NUM_YDET_VXRMS, vxrms); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_get_ydet_vyrms (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double vyrms; switch (event) { case EVENT_COMMIT: vibwire_get_ydet_vyrms(&vyrms); SetCtrlVal (panel, VIBWIREOP_NUM_YDET_VYRMS, vyrms); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_find_res_freq_coarse (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int har_num = 2; double coarse_res_freq; switch (event) { case EVENT_COMMIT: vibwire_find_res_freq_coarse('x', har_num, &coarse_res_freq, VIBWIRE_EXTRA_COARSE_NUM_FREQ); SetCtrlVal (panel, VIBWIREOP_NUM_RES_FREQ_COARSE, coarse_res_freq); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireuiop_find_res_freq_fine (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double coarse_res_freq; double fine_res_freq; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, VIBWIREOP_NUM_RES_FREQ_COARSE, &coarse_res_freq); vibwire_find_res_freq_fine('x', coarse_res_freq, &fine_res_freq); SetCtrlVal (panel, VIBWIREOP_NUM_RES_FREQ_FINE, fine_res_freq); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vibwireopui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vibwire_exit(); QuitUserInterface(0); break; } return 0; }