#include "Hp3458uir.h" /* ************************************************************** */ /* * Module HP3458UI * This module contains functions for the HP3458 multimeter * user interface. * * Zachary Wolf * 8/3/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "hp3458uir.h" #include "hp3458ui.h" #include "hp3458.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int hp3458_ID; static int hp3458_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void hp3458ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * hp3458ui_init * This function initializes the user interface for the HP3458 DMM. * * Input: * ID, HP3458 device identifier * * Zachary Wolf * 8/3/98 */ void hp3458ui_init(int ID) { /* Save the HP3458 ID */ hp3458_ID = ID; /* Open the HP3458 panel */ hp3458_panel = LoadPanel(0, "hp3458uir.uir", HPPANEL); if (hp3458_panel < 0) { hp3458ui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(hp3458_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * hp3458ui_error * This function handles error messages for the HP3458 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/3/98 */ void hp3458ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nHP3458UI 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 hp3458ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: hp3458_exit(hp3458_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp3458ui_get_voltage(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double voltage; switch (event) { case EVENT_COMMIT: hp3458_get_voltage(hp3458_ID, &voltage); SetCtrlVal(hp3458_panel, HPPANEL_HP3458_V, voltage); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp3458ui_get_frequency (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double frequency; switch (event) { case EVENT_COMMIT: hp3458_get_frequency(hp3458_ID, &frequency); SetCtrlVal(hp3458_panel, HPPANEL_HP3458_F, frequency); break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp3458ui_get_resistance (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double resistance; char buf[HP3458_MAX_CMD + 1]; switch (event) { case EVENT_COMMIT: printf("Are you sure that no voltage is applied to the HP3458??\n"); printf("Press ENTER to continue.\nPress any key then ENTER to exit R measurement.\n"); fgets(buf, 80, stdin); if (buf[0] != '\n') return 0; hp3458_get_resistance(hp3458_ID, &resistance); SetCtrlVal(hp3458_panel, HPPANEL_HP3458_R, resistance); break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp3458ui_get_temperature (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double temperature; char buf[HP3458_MAX_CMD + 1]; switch (event) { case EVENT_COMMIT: printf("Are you sure that no voltage is applied to the HP3458??\n"); printf("Press ENTER to continue.\nPress any key then ENTER to exit T measurement.\n"); fgets(buf, 80, stdin); if (buf[0] != '\n') return 0; hp3458_get_temperature(hp3458_ID, &temperature); SetCtrlVal(hp3458_panel, HPPANEL_HP3458_Tc, temperature); break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp3458ui_get_Vsamples (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int dev_ID; double v_range; double num_plc; int num_samples; double delta_t; double voltages[2000]; switch (event) { case EVENT_COMMIT: dev_ID = hp3458_ID; v_range = 5.; num_plc = 2.; num_samples = 60; delta_t = .1; hp3458_setup_timed_voltage_samples(dev_ID, v_range, num_plc, num_samples, delta_t); hp3458_trigger_timed_voltage_samples(dev_ID); hp3458_collect_timed_voltage_samples(dev_ID, num_samples, voltages); DeleteGraphPlot (hp3458_panel, HPPANEL_GRAPH_VvsT, -1, VAL_IMMEDIATE_DRAW); PlotY (hp3458_panel, HPPANEL_GRAPH_VvsT, voltages, num_samples, VAL_DOUBLE, VAL_THIN_LINE, VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp3458ui_digitize (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int dev_ID; int num_samples; double delta_t; double voltages[2000]; switch (event) { case EVENT_COMMIT: dev_ID = hp3458_ID; num_samples = 1000; delta_t = .0001; hp3458_digitize(dev_ID, num_samples, delta_t, voltages); DeleteGraphPlot (hp3458_panel, HPPANEL_GRAPH_VvsT, -1, VAL_IMMEDIATE_DRAW); PlotY (hp3458_panel, HPPANEL_GRAPH_VvsT, voltages, num_samples, VAL_DOUBLE, VAL_THIN_LINE, VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); break; } return 0; }