/* ************************************************************** */ /* * Module PM500UI * This module contains functions for the Klinger PM500 * user interface. * * Zachary Wolf * 8/5/99 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "pm500uir.h" #include "pm500ui.h" #include "pm500.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int pm500_ID; static int pm500_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void pm500ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * pm500ui_init * This function initializes the user interface for the PM500. * * Input: * ID, PM500 device identifier * * Zachary Wolf * 8/26/98 */ void pm500ui_init(int ID) { /* Save the device ID */ pm500_ID = ID; /* Open the PM500 panel */ pm500_panel = LoadPanel(0, "pm500uir.uir", PM500PAN); if (pm500_panel < 0) { pm500ui_error("Could not open user interface panel"); return; } /* Display the panel */ DisplayPanel(pm500_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * pm500ui_error * This function handles error messages for the PM500 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/26/98 */ void pm500ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nPM500UI 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 pm500ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: pm500_exit(pm500_ID); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK pm500ui_move(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double acc, vel, dis; char axis_str[PM500_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, PM500PAN_TXT_axis, axis_str); GetCtrlVal(panel, PM500PAN_NUM_acc, &acc); GetCtrlVal(panel, PM500PAN_NUM_vel, &vel); GetCtrlVal(panel, PM500PAN_NUM_dis, &dis); axis = axis_str[0]; pm500_rel_stage_move(pm500_ID, axis, acc, vel, dis); break; } return 0; } /* ************************************************************** */ int CVICALLBACK pm500ui_get_position(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; char axis_str[PM500_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, PM500PAN_TXT_axis, axis_str); axis = axis_str[0]; pm500_get_stage_pos(pm500_ID, axis, &pos); SetCtrlVal(panel, PM500PAN_NUM_POSITION, pos); break; } return 0; } /* ************************************************************** */ int CVICALLBACK pm500ui_zero(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; char axis_str[PM500_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: pm500_zero(pm500_ID); GetCtrlVal(panel, PM500PAN_TXT_axis, axis_str); axis = axis_str[0]; pm500_get_stage_pos(pm500_ID, axis, &pos); SetCtrlVal(panel, PM500PAN_NUM_POSITION, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; }