/* ************************************************************** */ /* * Module TELETRACUI * This module contains functions for the TELETRAC interferometer * user interface. * * Zachary Wolf * 1/21/03 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "teletracuir.h" #include "teletracui.h" #include "teletrac.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int teletrac_ID; static int teletrac_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void teletracui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * teletracui_init * This function initializes the user interface for the TELETRAC. * * Input: * ID, TELETRAC device identifier * * Zachary Wolf * 1/21/03 */ void teletracui_init(int ID) { /* Save the Gaussmeter ID */ teletrac_ID = ID; /* Open the TELETRAC panel */ teletrac_panel = LoadPanel(0, "teletracuir.uir", TELETRAPAN); if (teletrac_panel < 0) { teletracui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(teletrac_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * teletracui_error * This function handles error messages for the TELETRAC user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/3/98 */ void teletracui_error(char* message) { /* Declare variables */ char buf[TELETRAC_MAX_CMD]; /* Notify the operator of the error */ printf("\nTELETRACUI 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, TELETRAC_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK teletracui_zero(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char msg[TELETRAC_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(teletrac_panel, TELETRAPAN_STR_AXIS, msg); axis = msg[0]; teletrac_zero(teletrac_ID, axis); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK teletracui_get_pos(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char msg[TELETRAC_MAX_CMD]; char axis; double pos; switch (event) { case EVENT_COMMIT: GetCtrlVal(teletrac_panel, TELETRAPAN_STR_AXIS, msg); axis = msg[0]; teletrac_get_pos(teletrac_ID, axis, &pos); SetCtrlVal(teletrac_panel, TELETRAPAN_NUM_GET_POS, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK teletracui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: teletrac_exit(teletrac_ID); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }