/* ************************************************************** */ /* * Module VSCANUI * This module contains functions for the voltage scan * system user interface. * * Zachary Wolf * 10/23/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vscanuir.h" #include "vscanui.h" #include "vscan.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct vscan_param_struct vscan_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vscan_panel; static int vscanop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vscanui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vscanui_init * This function initializes the user interface for the VSCAN 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 * vscan_par, vscan system parameters * * Zachary Wolf * 10/23/02 */ void vscanui_init(int top_pos, int left_pos, struct vscan_param_struct vscan_par) { /* Save parameters for future use */ vscan_param = vscan_par; /* Make sure the user interface panel is desired */ if (vscan_param.show_ui != VSCAN_TRUE) return; /* Open the vscan panel */ vscan_panel = LoadPanel(0, "c:\\dataccvi\\lib\\system\\vscan\\vscanuir.uir", VSCANPAN); if (vscan_panel < 0) { vscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vscan_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vscan_panel); /* Done */ return; } /* ************************************************************** */ /* * vscanopui_init * This function initializes the user interface for the VSCAN 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/23/02 */ void vscanopui_init(int top_pos, int left_pos) { /* Open the vscanop panel */ vscanop_panel = LoadPanel(0, "vscanuir.uir", VSCANOP); if (vscan_panel < 0) { vscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vscanop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(vscanop_panel); /* Done */ return; } /* ************************************************************** */ void vscanui_clear_vsamp(void) { /* Check for the user interface */ if (vscan_param.show_ui != VSCAN_TRUE) return; /* Remove previous voltage sample plot */ DeleteGraphPlot(vscan_panel, VSCANPAN_GRAPH_V_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ void vscanui_plot_vsamp(int num_samp, double pos_samp[], double v_samp[], long int color) { /* Check for the user interface */ if (vscan_param.show_ui != VSCAN_TRUE) return; /* Plot the voltage samples */ PlotXY(vscan_panel, VSCANPAN_GRAPH_V_SAMP, pos_samp, v_samp, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, color); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vscanui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 10/23/02 */ void vscanui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVSCANUI 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); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK vscanui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vscan_exit(); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vscanui_get_vsamp(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double start_pos; double dist_move; int num_dvm; struct vscan_dvm_info_struct dvm_info[VSCAN_MAX_NUM_DVM]; int num_samp; double pos_samp[VSCAN_MAX_NUM_SAMP]; double v_samp[VSCAN_MAX_NUM_DVM][VSCAN_MAX_NUM_SAMP]; int i, j; long int color[3] = {VAL_RED, VAL_GREEN, VAL_BLUE}; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, VSCANOP_START_POS, &start_pos); GetCtrlVal (panel, VSCANOP_DIST_MOVE, &dist_move); vscan_get_v(start_pos, dist_move, &num_dvm, dvm_info, &num_samp, pos_samp, v_samp); vscanui_clear_vsamp(); for (i = 0; i < num_dvm; i++) {for (j = 0; j < num_samp; j++) v_samp[i][j] += i;} for (i = 0; i < num_dvm; i++) vscanui_plot_vsamp(num_samp, pos_samp, v_samp[i], color[i % 3]); vscan_move_probe_abs(0.); break; case EVENT_RIGHT_CLICK: break; } return 0; }