/* ************************************************************** */ /* * Module EF11PRUI * This module contains functions for the Mitutoyo EF11PR * user interface. * * Zachary Wolf * 11/29/01 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "ef11pruir.h" #include "ef11prui.h" #include "ef11pr.h" #include "ef11pruir.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int ef11pr_ID; static int ef11pr_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void ef11prui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * ef11prui_init * This function initializes the user interface for the EF11PR. * * Input: * ID, EF11PR device identifier * * Zachary Wolf * 11/29/01 */ void ef11prui_init(int ID) { /* Save the Gaussmeter ID */ ef11pr_ID = ID; /* Open the EF11PR panel */ ef11pr_panel = LoadPanel(0, "ef11pruir.uir", EF11PRPAN); if (ef11pr_panel < 0) { ef11prui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(ef11pr_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * ef11prui_error * This function handles error messages for the EF11PR user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/3/98 */ void ef11prui_error(char* message) { /* Declare variables */ char buf[EF11PR_MAX_CMD]; /* Notify the operator of the error */ printf("\nEF11PRUI 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, EF11PR_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK ef11prui_timer (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; switch (event) { case EVENT_TIMER_TICK: ef11pr_get_pos(ef11pr_ID, &pos); SetCtrlVal(ef11pr_panel, EF11PRPAN_NUMERICMETER, pos*1.e6); break; } return 0; } /* ************************************************************** */ int CVICALLBACK ef11prui_get_pos(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; switch (event) { case EVENT_COMMIT: ef11pr_get_pos(ef11pr_ID, &pos); SetCtrlVal(ef11pr_panel, EF11PRPAN_NUM_GET_POS, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK ef11prui_zero(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; switch (event) { case EVENT_COMMIT: ef11pr_zero(ef11pr_ID); ef11pr_get_pos(ef11pr_ID, &pos); SetCtrlVal(ef11pr_panel, EF11PRPAN_NUM_GET_POS, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK ef11prui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: ef11pr_exit(ef11pr_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }