/* ************************************************************** */ /* * Module DAC488HRUI * This module contains functions for the IOtech DAC488HR * user interface. * * Zachary Wolf * 7/27/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "dac488hruir.h" #include "dac488hrui.h" #include "dac488hr.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int dac488hr_ID; static int dac488hr_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void dac488hrui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * dac488hrui_init * This function initializes the user interface for the DAC488HR. * * Input: * ID, DAC488HR device identifier * * Zachary Wolf * 8/3/98 */ void dac488hrui_init(int ID) { /* Save the DAC ID */ dac488hr_ID = ID; /* Open the DAC488HR panel */ dac488hr_panel = LoadPanel(0, "dac488hruir.uir", DACPANEL); if (dac488hr_panel < 0) { dac488hrui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(dac488hr_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * dac488hrui_error * This function handles error messages for the DAC488HR user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/3/98 */ void dac488hrui_error(char* message) { /* Declare variables */ char buf[DAC488HR_MAX_CMD]; /* Notify the operator of the error */ printf("\nDAC488HRUI 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, DAC488HR_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK dac488hrui_set_port_voltage(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int port; double voltage; switch (event) { case EVENT_COMMIT: GetCtrlVal(dac488hr_panel, DACPANEL_PORT, &port); GetCtrlVal(dac488hr_panel, DACPANEL_NUM_SET_PORT_VOLTAGE, &voltage); dac488hr_set_port_voltage(dac488hr_ID, port, voltage); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488hrui_get_port_voltage(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int port; double voltage; switch (event) { case EVENT_COMMIT: GetCtrlVal(dac488hr_panel, DACPANEL_PORT, &port); dac488hr_get_port_voltage(dac488hr_ID, port, &voltage); SetCtrlVal(dac488hr_panel, DACPANEL_NUM_GET_PORT_VOLTAGE, voltage); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488hrui_set_digital_output(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int config; switch (event) { case EVENT_COMMIT: GetCtrlVal(dac488hr_panel, DACPANEL_NUM_SET_DIGITAL_OUT, &config); dac488hr_set_digital_output(dac488hr_ID, config); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488hrui_get_digital_output(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int config; switch (event) { case EVENT_COMMIT: dac488hr_get_digital_output(dac488hr_ID, &config); SetCtrlVal(dac488hr_panel, DACPANEL_NUM_GET_DIGITAL_OUT, config); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488hrui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: dac488hr_exit(dac488hr_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }