/* ************************************************************** */ /* * Module MC4UI * This module contains functions for the Klinger MC4 * user interface. * * Zachary Wolf * 8/5/99 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "mc4uir.h" #include "mc4ui.h" #include "mc4.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int mc4_ID; static int mc4_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void mc4ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * mc4ui_init * This function initializes the user interface for the MC4. * * Input: * ID, MC4 device identifier * * Zachary Wolf * 8/26/98 */ void mc4ui_init(int ID) { /* Save the device ID */ mc4_ID = ID; /* Open the MC4 panel */ mc4_panel = LoadPanel(0, "mc4uir.uir", MC4PAN); if (mc4_panel < 0) { mc4ui_error("Could not open user interface panel"); return; } /* Display the panel */ DisplayPanel(mc4_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * mc4ui_error * This function handles error messages for the MC4 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/26/98 */ void mc4ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nMC4UI 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 mc4ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: mc4_exit(mc4_ID); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK mc4ui_move(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double acc, vel, dis; char axis_str[MC4_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, MC4PAN_TXT_axis, axis_str); GetCtrlVal(panel, MC4PAN_NUM_acc, &acc); GetCtrlVal(panel, MC4PAN_NUM_vel, &vel); GetCtrlVal(panel, MC4PAN_NUM_dis, &dis); axis = axis_str[0]; mc4_rel_stage_move(mc4_ID, axis, acc, vel, dis); break; } return 0; } /* ************************************************************** */ int CVICALLBACK mc4ui_get_position(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; char axis_str[MC4_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, MC4PAN_TXT_axis, axis_str); axis = axis_str[0]; mc4_get_stage_pos(mc4_ID, axis, &pos); SetCtrlVal(panel, MC4PAN_NUM_POSITION, pos); break; } return 0; } /* ************************************************************** */ int CVICALLBACK mc4ui_zero(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; char axis_str[MC4_MAX_CMD]; char axis; switch (event) { case EVENT_COMMIT: mc4_zero(mc4_ID); GetCtrlVal(panel, MC4PAN_TXT_axis, axis_str); axis = axis_str[0]; mc4_get_stage_pos(mc4_ID, axis, &pos); SetCtrlVal(panel, MC4PAN_NUM_POSITION, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK mc4ui_move_2(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double acc, vel, dis; char axis_str[MC4_MAX_CMD]; char axis1, axis2; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, MC4PAN_TXT_axis_2_1, axis_str); axis1 = axis_str[0]; GetCtrlVal(panel, MC4PAN_TXT_axis_2_2, axis_str); axis2 = axis_str[0]; GetCtrlVal(panel, MC4PAN_NUM_acc_2, &acc); GetCtrlVal(panel, MC4PAN_NUM_vel_2, &vel); GetCtrlVal(panel, MC4PAN_NUM_dis_2, &dis); mc4_rel_2_stage_move(mc4_ID, axis1, axis2, acc, vel, dis); break; } return 0; } /* ************************************************************** */ int CVICALLBACK mc4ui_get_position_2(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos1, pos2, pos; char axis_str[MC4_MAX_CMD]; char axis1, axis2; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, MC4PAN_TXT_axis_2_1, axis_str); axis1 = axis_str[0]; GetCtrlVal(panel, MC4PAN_TXT_axis_2_2, axis_str); axis2 = axis_str[0]; mc4_get_stage_pos(mc4_ID, axis1, &pos1); mc4_get_stage_pos(mc4_ID, axis2, &pos2); pos = (pos1 + pos2) / 2.; SetCtrlVal(panel, MC4PAN_NUM_POSITION_2, pos); break; } return 0; } /* ************************************************************** */ int CVICALLBACK mc4ui_zero_2(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos1, pos2, pos; char axis_str[MC4_MAX_CMD]; char axis1, axis2; switch (event) { case EVENT_COMMIT: mc4_zero(mc4_ID); GetCtrlVal(panel, MC4PAN_TXT_axis_2_1, axis_str); axis1 = axis_str[0]; GetCtrlVal(panel, MC4PAN_TXT_axis_2_2, axis_str); axis2 = axis_str[0]; mc4_get_stage_pos(mc4_ID, axis1, &pos1); mc4_get_stage_pos(mc4_ID, axis2, &pos2); pos = (pos1 + pos2) / 2.; SetCtrlVal(panel, MC4PAN_NUM_POSITION_2, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; }