/* ************************************************************** */ /* * Module VTSCANUI * This module contains functions for the stretched wire integrated * voltage system user interface. * * Zachary Wolf * 9/18/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vtscanuir.h" #include "vtscanui.h" #include "vtscan.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct vtscan_param_struct vtscan_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vtscan_panel; static int vtscanop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vtscanui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vtscanui_init * This function initializes the user interface for the VTwire 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 * vtscan_par, vtscan system parameters * * Zachary Wolf * 9/18/98 */ void vtscanui_init(int top_pos, int left_pos, struct vtscan_param_struct vtscan_par) { /* Save parameters for future use */ vtscan_param = vtscan_par; /* Make sure the user interface panel is desired */ if (vtscan_param.show_ui != VTSCAN_TRUE) return; /* Open the VTscan panel */ vtscan_panel = LoadPanel(0, "c:\\dataccvi\\lib\\system\\vtscan\\vtscanuir.uir", VTSCANPAN); if (vtscan_panel < 0) { vtscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vtscan_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vtscan_panel); /* Done */ return; } /* ************************************************************** */ /* * vtscanopui_init * This function initializes the user interface for the VTwire 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 * 9/18/98 */ void vtscanopui_init(int top_pos, int left_pos) { /* Open the VTwire panel */ vtscanop_panel = LoadPanel(0, "vtscanuir.uir", VTSCANOP); if (vtscan_panel < 0) { vtscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vtscanop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(vtscanop_panel); /* Done */ return; } /* ************************************************************** */ /* * vtscanui_scale_vt_vs_x * This function sets the scale on the horizontal axis of the VT vs X * plot. * * Input: * num_x_pos, number of x positions * x_pos[0 to num_x_pos - 1], x positions * * Zachary Wolf * 3/17/00 */ void vtscanui_scale_vt_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 (vtscan_param.show_ui != VTSCAN_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 VT vs X plot */ SetAxisRange(vtscan_panel, VTSCANPAN_GRAPH_VT_SAMP, VAL_MANUAL, x_min, x_max, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ void vtscanui_clear_vt_vs_x(void) { /* Check for the user interface */ if (vtscan_param.show_ui != VTSCAN_TRUE) return; /* Remove previous VT sample plot */ DeleteGraphPlot(vtscan_panel, VTSCANPAN_GRAPH_VT_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ void vtscanui_plot_vt_vs_x(int num_samp, double x[], double vt[], int color) { /* Check for the user interface */ if (vtscan_param.show_ui != VTSCAN_TRUE) return; /* Plot the VT samples */ PlotXY(vtscan_panel, VTSCANPAN_GRAPH_VT_SAMP, x, vt, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, color); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vtscanui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 9/18/98 */ void vtscanui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVTSCANUI 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 vtscanui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vtscan_exit(); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vtscanui_get_vt(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double x0, dx; double x[5000]; double vt[5000]; int num_samp; x0 = 0.; dx = .02; num_samp = 200; switch (event) { case EVENT_COMMIT: vtscan_get_vt(x0, dx, num_samp, x, vt); vtscanui_plot_vt_vs_x(num_samp, x, vt, VAL_RED); vtscan_move_wire_abs(0.); break; case EVENT_RIGHT_CLICK: break; } return 0; }