/* ************************************************************** */ /* * Module WIRPOSUI * This module contains functions for the wire position detector * system user interface. * * Zachary Wolf * 7/27/05 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "wirposuir.h" #include "wirposui.h" #include "wirpos.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct wirpos_param_struct wirpos_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int wirpos_panel; static int wirposop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void wirposui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * wirposui_init * This function initializes the user interface for the WIRPOS 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 * wirpos_par, wirpos system parameters * * Zachary Wolf * 7/27/05 */ void wirposui_init(int top_pos, int left_pos, struct wirpos_param_struct wirpos_par) { /* Save parameters for future use */ wirpos_param = wirpos_par; /* Make sure the user interface panel is desired */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Open the wirpos panel */ wirpos_panel = LoadPanel(0, "c:\\dataccvi\\lib\\system\\wirpos\\wirposuir.uir", WIRPOSPAN); if (wirpos_panel < 0) { wirposui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(wirpos_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(wirpos_panel); /* Done */ return; } /* ************************************************************** */ /* * wirposopui_init * This function initializes the user interface for the WIRPOS 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 * 7/27/05 */ void wirposopui_init(int top_pos, int left_pos) { /* Open the wirposop panel */ wirposop_panel = LoadPanel(0, "wirposuir.uir", WIRPOSOP); if (wirpos_panel < 0) { wirposui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(wirposop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(wirposop_panel); /* Done */ return; } /* ************************************************************** */ void wirposui_clear_graph(void) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Remove previous field sample plot */ DeleteGraphPlot(wirpos_panel, WIRPOSPAN_GRAPH_V_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ void wirposui_setup_graph(double x_min, double x_max, double y_min, double y_max) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Setup the axes for the plot */ SetAxisRange(wirpos_panel, WIRPOSPAN_GRAPH_V_SAMP, VAL_MANUAL, x_min, x_max, VAL_MANUAL, y_min, y_max); ProcessDrawEvents(); /* Done */ return; } /* ************************************************************** */ void wirposui_plot_x_v_samp(double x, double v) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Plot the field sample */ PlotPoint(wirpos_panel, WIRPOSPAN_GRAPH_V_SAMP, x, v, VAL_SOLID_SQUARE, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ void wirposui_plot_x_v_thresh(double x, double v) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Plot the field sample */ PlotPoint(wirpos_panel, WIRPOSPAN_GRAPH_V_SAMP, x, v, VAL_SOLID_CIRCLE, VAL_RED); /* Done */ return; } /* ************************************************************** */ void wirposui_plot_x_v_wire(double x, double v) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Plot the field sample */ PlotPoint(wirpos_panel, WIRPOSPAN_GRAPH_V_SAMP, x, v, VAL_BOLD_X, VAL_RED); /* Done */ return; } /* ************************************************************** */ void wirposui_plot_line(double x1, double y1, double x2, double y2) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Plot the field sample */ PlotLine(wirpos_panel, WIRPOSPAN_GRAPH_V_SAMP, x1, y1, x2, y2, VAL_GREEN); /* Done */ return; } /* ************************************************************** */ void wirposui_set_det_num(int det_num) { /* Check for the user interface */ if (wirpos_param.show_ui != WIRPOS_TRUE) return; /* Display the detector number */ SetCtrlVal(wirpos_panel, WIRPOSPAN_NUM_DET_NUM, det_num+1); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * wirposui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 7/27/05 */ void wirposui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nWIRPOSUI 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 wirposopui_move_home (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); wirpos_move_home(det_num-1); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_rel_move (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; double dis; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); GetCtrlVal (panel, WIRPOSOP_REL_MOVE, &dis); wirpos_rel_move(det_num-1, dis); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_abs_move (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; double pos; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); GetCtrlVal (panel, WIRPOSOP_ABS_MOVE, &pos); wirpos_abs_move(det_num-1, pos); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_set_zero_pos (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); wirpos_set_zero_pos(det_num-1); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_get_v (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; double v; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); wirpos_get_volt(det_num-1, &v); SetCtrlVal (panel, WIRPOSOP_NUM_V, v); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_get_x (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; double x; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); wirpos_get_pos(det_num-1, &x); SetCtrlVal (panel, WIRPOSOP_NUM_X, x); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_find_wire_coarse (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; double coarse_wire_pos; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); wirpos_find_wire_coarse(det_num-1, &coarse_wire_pos); SetCtrlVal (panel, WIRPOSOP_NUM_X_COARSE, coarse_wire_pos); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposuiop_find_wire_fine (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int det_num; double coarse_wire_pos; double x; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, WIRPOSOP_NUM_DET_NUM_OP, &det_num); GetCtrlVal (panel, WIRPOSOP_NUM_X_COARSE, &coarse_wire_pos); wirpos_find_wire_fine(det_num-1, coarse_wire_pos, &x); SetCtrlVal (panel, WIRPOSOP_NUM_X_FINE, x); break; } return 0; } /* ************************************************************** */ int CVICALLBACK wirposopui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: wirpos_exit(); QuitUserInterface(0); break; } return 0; }