/* ************************************************************** */ /* * Module PDI5025UI * This module contains functions for the Metrolab PDI5025 * user interface. * * Zachary Wolf * 9/6/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "pdi5025uir.h" #include "pdi5025ui.h" #include "pdi5025.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int pdi5025_ID; static int pdi5025_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void pdi5025ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * pdi5025ui_init * This function initializes the user interface for the PDI5025. * * Input: * ID, PDI5025 device identifier * * Zachary Wolf * 9/6/98 */ void pdi5025ui_init(int ID) { /* Save the device ID */ pdi5025_ID = ID; /* Open the PDI5025 panel */ pdi5025_panel = LoadPanel(0, "pdi5025uir.uir", PDI5025PAN); if (pdi5025_panel < 0) { pdi5025ui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(pdi5025_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * pdi5025ui_error * This function handles error messages for the PDI5025 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/26/98 */ void pdi5025ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nPDI5025UI 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 pdi5025ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: pdi5025_exit(pdi5025_ID); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK pdi5025ui_get_VT_timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char chan_string[2]; char chan; int gain; double delta_t_samp; int num_samp; double vt[5000]; double vt_time[5000]; double integrated_voltage; int i; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, PDI5025PAN_STR_INT_CHAN, chan_string); chan = chan_string[0]; GetCtrlVal(panel, PDI5025PAN_NUM_GAIN, &gain); GetCtrlVal(panel, PDI5025PAN_NUM_TIME_BETWEEN_SAMP, &delta_t_samp); GetCtrlVal(panel, PDI5025PAN_NUM_NUM_SAMPLES, &num_samp); pdi5025_get_VT_timer(pdi5025_ID, chan, gain, delta_t_samp, num_samp, vt); integrated_voltage = vt[num_samp]; SetCtrlVal(panel, PDI5025PAN_NUM_INTEGRATED_VOLTAG, integrated_voltage); DeleteGraphPlot(panel, PDI5025PAN_GRAPH_VT_SAMP, -1, VAL_IMMEDIATE_DRAW); for (i = 0; i <= num_samp; i++) vt_time[i] = i * delta_t_samp; PlotXY(panel, PDI5025PAN_GRAPH_VT_SAMP, vt_time, vt, num_samp + 1, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_SOLID_CIRCLE, VAL_SOLID, 1, VAL_RED); break; } return 0; }