/* ************************************************************** */ /* * Module HP34970UI * This module contains functions for the HP34970 multimeter * user interface. * * Zachary Wolf * 2/19/03 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "hp34970uir.h" #include "hp34970ui.h" #include "hp34970.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int hp34970_ID; static int hp34970_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void hp34970ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * hp34970ui_init * This function initializes the user interface for the HP34970 DMM. * * Input: * ID, HP34970 device identifier * * Zachary Wolf * 2/19/03 */ void hp34970ui_init(int ID) { /* Save the HP34970 ID */ hp34970_ID = ID; /* Open the HP34970 panel */ hp34970_panel = LoadPanel(0, "hp34970uir.uir", HPPANEL); if (hp34970_panel < 0) { hp34970ui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(hp34970_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * hp34970ui_error * This function handles error messages for the HP34970 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 2/19/03 */ void hp34970ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nHP34970UI 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 hp34970ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: hp34970_exit(hp34970_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp34970ui_get_chan_volt(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int chan; double volt; static double setvolt; static double callnum = 0; int key =0; if(callnum == 0) { GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_volt(hp34970_ID, chan, &setvolt); callnum++; } switch (event) { case EVENT_TIMER_TICK: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_volt(hp34970_ID, chan, &volt); SetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN_VOLT, volt-setvolt); break; case EVENT_LEFT_CLICK: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_volt(hp34970_ID, chan, &setvolt); setvolt = 5; break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp34970ui_get_chan_res(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int chan; double res; switch (event) { case EVENT_COMMIT: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_res(hp34970_ID, chan, &res); SetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN_RES, res); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp34970ui_get_chan_4wire_res(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int chan; double res; switch (event) { case EVENT_COMMIT: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_4wire_res(hp34970_ID, chan, &res); SetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN_4WIRE_R, res); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp34970ui_get_chan_temp(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int chan; double temp; switch (event) { case EVENT_COMMIT: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_temp(hp34970_ID, chan, &temp); SetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN_TEMP, temp); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp34970ui_get_chan_freq(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int chan; double freq; switch (event) { case EVENT_COMMIT: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_freq(hp34970_ID, chan, &freq); SetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN_FREQ, freq); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp34970ui_get_chan_per(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int chan; double per; switch (event) { case EVENT_COMMIT: GetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN, &chan); hp34970_get_chan_per(hp34970_ID, chan, &per); SetCtrlVal(hp34970_panel, HPPANEL_HP34970_CHAN_PER, per); break; case EVENT_RIGHT_CLICK: break; } return 0; }