/* ************************************************************** */ /* * Module DAC488UI * This module contains functions for the IOtech DAC488 * user interface. * * Zachary Wolf * 7/27/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "dac488uir.h" #include "dac488ui.h" #include "dac488.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int dac488_ID; static int dac488_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void dac488ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * dac488ui_init * This function initializes the user interface for the DAC488. * * Input: * ID, DAC488 device identifier * * Zachary Wolf * 8/3/98 */ void dac488ui_init(int ID) { /* Save the DAC ID */ dac488_ID = ID; /* Open the DAC488 panel */ dac488_panel = LoadPanel(0, "dac488uir.uir", DACPANEL); if (dac488_panel < 0) { dac488ui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(dac488_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * dac488ui_error * This function handles error messages for the DAC488 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/3/98 */ void dac488ui_error(char* message) { /* Declare variables */ char buf[DAC488_MAX_CMD]; /* Notify the operator of the error */ printf("\nDAC488UI 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, DAC488_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK dac488ui_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(dac488_panel, DACPANEL_PORT, &port); GetCtrlVal(dac488_panel, DACPANEL_NUM_SET_PORT_VOLTAGE, &voltage); dac488_set_port_voltage(dac488_ID, port, voltage); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488ui_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(dac488_panel, DACPANEL_PORT, &port); dac488_get_port_voltage(dac488_ID, port, &voltage); SetCtrlVal(dac488_panel, DACPANEL_NUM_GET_PORT_VOLTAGE, voltage); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488ui_set_digital_output(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int config; switch (event) { case EVENT_COMMIT: GetCtrlVal(dac488_panel, DACPANEL_NUM_SET_DIGITAL_OUT, &config); dac488_set_digital_output(dac488_ID, config); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488ui_get_digital_output(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int config; switch (event) { case EVENT_COMMIT: dac488_get_digital_output(dac488_ID, &config); SetCtrlVal(dac488_panel, DACPANEL_NUM_GET_DIGITAL_OUT, config); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK dac488ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: dac488_exit(dac488_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }