/* ************************************************************** */ /* * Module ESP7000UI * This module contains functions for the Newport ESP7000 * user interface. * * Zachary Wolf * 5/27/05 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "esp7000uir.h" #include "esp7000ui.h" #include "esp7000.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int esp7000_ID; static int esp7000_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void esp7000ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * esp7000ui_init * This function initializes the user interface for the ESP7000. * * Input: * ID, ESP7000 device identifier * * Zachary Wolf * 5/27/05 */ void esp7000ui_init(int ID) { /* Save the device ID */ esp7000_ID = ID; /* Open the ESP7000 panel */ esp7000_panel = LoadPanel(0, "esp7000uir.uir", ESP7000PAN); if (esp7000_panel < 0) { esp7000ui_error("Could not open user interface panel"); return; } /* Display the panel */ DisplayPanel(esp7000_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * esp7000ui_error * This function handles error messages for the ESP7000 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 5/27/05 */ void esp7000ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nESP7000UI 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 esp7000ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: esp7000_exit(esp7000_ID); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK esp7000ui_move(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int axis; double acc, vel, dis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, ESP7000PAN_NUM_axis, &axis); GetCtrlVal(panel, ESP7000PAN_NUM_acc, &acc); GetCtrlVal(panel, ESP7000PAN_NUM_vel, &vel); GetCtrlVal(panel, ESP7000PAN_NUM_dis, &dis); acc = acc / 1.e3; vel = vel / 1.e3; dis = dis / 1.e3; esp7000_rel_stage_move(esp7000_ID, axis, acc, vel, dis); break; } return 0; } /* ************************************************************** */ int CVICALLBACK esp7000ui_get_position(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; int axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, ESP7000PAN_NUM_axis, &axis); esp7000_get_pos(esp7000_ID, axis, &pos); SetCtrlVal(panel, ESP7000PAN_NUM_POSITION, pos * 1.e3); break; } return 0; } /* ************************************************************** */ int CVICALLBACK esp7000ui_zero(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; int axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, ESP7000PAN_NUM_axis, &axis); esp7000_zero(esp7000_ID, axis); esp7000_get_pos(esp7000_ID, axis, &pos); SetCtrlVal(panel, ESP7000PAN_NUM_POSITION, pos * 1.e3); break; case EVENT_RIGHT_CLICK: break; } return 0; }