/* ************************************************************** */ /* * Module SENVSUI * This module contains functions for the sensor vs z measurements * user interface. * * Zachary Wolf * 2/16/01 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "sensor vs z uir.h" #include "sensor vs z ui.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int senvsz_panel; static int senvsz_num_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void senvszui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * senvszui_init * This function initializes the user interface for the Sensor vs Z 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 * 2/16/01 */ void senvszui_init(int top_pos, int left_pos) { /* Open the Sensor vs Z panel */ senvsz_panel = LoadPanel(0, "sensor vs z uir.uir", SENVSZPAN); if (senvsz_panel < 0) { senvszui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(senvsz_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(senvsz_panel); /* Open the Sensor vs Z numbers panel */ senvsz_num_panel = LoadPanel(0, "sensor vs z uir.uir", NUMPAN); if (senvsz_num_panel < 0) { senvszui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(senvsz_num_panel, top_pos, left_pos + 325 + 10); /* Display the panel */ DisplayPanel(senvsz_num_panel); /* Done */ return; } /* ************************************************************** */ /* * senvszui_scale_horiz_axis * This function sets the scale on the horizontal axis of the * Sensor vs Z graph. * * Input: * num_z_pos, number of z positions * z_pos[0 to num_z_pos - 1], z positions * * Zachary Wolf * 2/16/01 */ void senvszui_scale_horiz_axis(int num_z_pos, double z_pos[]) { /* Declare variables */ double z_min, z_max; int min_index, max_index; /* Determine the minimum and maximum z positions */ MaxMin1D(z_pos, num_z_pos, &z_max, &max_index, &z_min, &min_index); z_min = z_min; z_max = z_max; /* Set the horizontal scale of the Gap vs Z plots */ SetAxisRange(senvsz_panel, SENVSZPAN_GRAPH_V_VS_Z, VAL_MANUAL, z_min, z_max, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ void senvszui_update_meas(double z, int num_sen, double v[]) { /* Declare variables */ int i; int color_vals[] = {VAL_RED, VAL_GREEN, VAL_BLUE, VAL_CYAN, VAL_MAGENTA, VAL_YELLOW, VAL_DK_RED}; int color = 0; char values_string[200]; /* Plot the sensor voltages */ for (i = 0; i < num_sen; i++) { color++; color = color % 7; PlotPoint(senvsz_panel, SENVSZPAN_GRAPH_V_VS_Z, z, v[i], VAL_SMALL_SOLID_SQUARE, color_vals[color]); } /* Write the values */ sprintf(values_string, "%7.3f", z); for (i = 0; i < num_sen; i++) sprintf(values_string, "%s %7.3f",values_string, v[i]); sprintf(values_string, "%s\n", values_string); SetCtrlVal(senvsz_num_panel, NUMPAN_TEXTBOX_NUM, values_string); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * senvszui_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 senvszui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nSENUI 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); }