#include "Hp33220uir.h" /* ************************************************************** */ /* * Module HP33220UI * This module contains functions for the HP33220 function generator * user interface. * * Zachary Wolf * 8/26/04 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "hp33220uir.h" #include "hp33220ui.h" #include "hp33220.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int hp33220_ID; static int hp33220_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void hp33220ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * hp33220ui_init * This function initializes the user interface for the HP33220 DMM. * * Input: * ID, HP33220 device identifier * * Zachary Wolf * 8/26/04 */ void hp33220ui_init(int ID) { /* Save the HP33220 ID */ hp33220_ID = ID; /* Open the HP33220 panel */ hp33220_panel = LoadPanel(0, "hp33220uir.uir", HPPANEL); if (hp33220_panel < 0) { hp33220ui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(hp33220_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * hp33220ui_error * This function handles error messages for the HP33220 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/26/04 */ void hp33220ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nHP33220UI 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 hp33220ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: hp33220_exit(hp33220_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK hp33220ui_set (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int waveform; double ampl; double freq; double offset; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, HPPANEL_RING_WAVEFORM, &waveform); GetCtrlVal(panel, HPPANEL_NUMERIC_AMPL, &l); GetCtrlVal(panel, HPPANEL_NUMERIC_FREQ, &freq); GetCtrlVal(panel, HPPANEL_NUMERIC_DC_OFFSET, &offset); if (waveform == 0) hp33220_output_sine(hp33220_ID, ampl, freq); else if (waveform == 1) hp33220_output_square(hp33220_ID, ampl, freq, 50.); else if (waveform == 2) hp33220_output_ramp(hp33220_ID, ampl, freq, 100.); else hp33220ui_error("hp33220ui_set: Unknown waveform."); hp33220_set_dc_offset(hp33220_ID, offset); break; } return 0; }