#include // ************************************************************** // // Module XPS_C8 // This module contains functions for the Newport XPS-C8 Controller // user interface. // // Yurii Levashov & Seva // 11/03/2005 // // ************************************************************** // INCLUDES #include #include #include #include "xps_c8uir.h" #include "xps_c8.h" #define XPS_C8_MAX_CMD 10 // ************************************************************** // PRIVATE VARIABLES static int SocketID; static int xps_c8_panel; static int server_connect = 0; char msg[260]; static XPS_PARAM xps_c8_param; static int x_stage_init = 0; static int y_stage_init = 0; static int xps_c8_ID = -1; // ************************************************************** // PRIVATE FUNCTION DECLARATIONSS void xps_c8ui_error(char* msg); // ************************************************************** // PUBLIC FUNCTIONS // ************************************************************** // // xps_c8ui_init // This function initializes the user interface for the XPS-C8. // // Input: // ID, XPS device identifier // // Yurii Levashov // 11/03/2005 void xps_c8ui_init(void) { int devCount = 0; // Open the XPS panel xps_c8_panel = LoadPanel(0, "xps_c8uir.uir", XPS_PANEL); if (xps_c8_panel < 0) { xps_c8ui_error("Could not open user interface panel"); return; } // Display the panel when the user interface runs DisplayPanel(xps_c8_panel); devCount = xps_c8_init(&xps_c8_ID); if(devCount < 1) xps_c8ui_error("Could not start XPS C8 driver"); return; } // ************************************************************** // PRIVATE FUNCTIONS // ************************************************************** // // xps_c8ui_error // This function handles error messages for the XPS user interface. // // Input: // message, string to display in standard I/O // // Yurii Levashov // 11/03/2005 // void xps_c8ui_error(char* message) { char buf[XPS_C8_MAX_CMD]; printf("\nXPS_C8UI 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, XPS_C8_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } // ************************************************************** // // PRIVATE USER INTERFACE FUNCTIONS // // ************************************************************** // int CVICALLBACK xps_exit (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: xps_c8_exit(xps_c8_ID); DiscardPanel (panel); QuitUserInterface (0); break; case EVENT_LEFT_CLICK: break; case EVENT_RIGHT_CLICK: break; } return 0; } int CVICALLBACK OnXps_move_rel (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double distance = 0.; double position[2] = {0.}; int group = 0; int result = 0; int mode = 0; switch (event) { case EVENT_COMMIT: if(GetCtrlAttribute (panel, XPS_PANEL_XPS_DISTANCE, ATTR_CTRL_VAL, &distance) < 0) xps_c8ui_error("Problem reading distance"); //distance *= -1000.; //convert to mm; change sign to move in the right direction if(GetCtrlAttribute (panel, XPS_PANEL_GROUP_SEL, ATTR_CTRL_VAL, &group) < 0) xps_c8ui_error("Problem reading group"); GetCtrlVal(panel,XPS_PANEL_GROUP_MODE,&mode); xps_c8_set_group_mode(group,mode); result = xps_c8_move_rel(xps_c8_ID, group, distance, position); switch(group) { case 0: if(SetCtrlAttribute (panel, XPS_PANEL_XPS_XX, ATTR_CTRL_VAL, position[0] ) < 0) xps_c8ui_error("Problem setting distance X"); if(SetCtrlAttribute (panel, XPS_PANEL_XPS_XX_2, ATTR_CTRL_VAL, position[1] ) < 0) xps_c8ui_error("Problem setting distance X"); printf("\n Relative move XX done"); break; case 1: if(SetCtrlAttribute (panel, XPS_PANEL_XPS_YY, ATTR_CTRL_VAL, position[0] ) < 0) xps_c8ui_error("Problem setting distance Y"); if(SetCtrlAttribute (panel, XPS_PANEL_XPS_YY_2, ATTR_CTRL_VAL, position[1] ) < 0) xps_c8ui_error("Problem setting distance Y"); printf("\n Relative move YY done"); break; } break; case EVENT_LEFT_CLICK: break; case EVENT_RIGHT_CLICK: break; } return 0; } int CVICALLBACK OnXps_move_abs (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double distance = 0.; double position[2] ={0.}; int group = 0; int result = -1; int mode = 0; switch (event) { case EVENT_COMMIT: if(GetCtrlAttribute (panel, XPS_PANEL_XPS_DISTANCE, ATTR_CTRL_VAL, &distance) < 0) xps_c8ui_error("Problem reading distance"); //distance *= -1000.; //convert to mm; change sign to move in the right direction if(GetCtrlAttribute (panel, XPS_PANEL_GROUP_SEL, ATTR_CTRL_VAL, &group) < 0) xps_c8ui_error("Problem reading group"); GetCtrlVal(panel,XPS_PANEL_GROUP_MODE,&mode); xps_c8_set_group_mode(group,mode); result = xps_c8_move_abs(xps_c8_ID, group, distance , position); switch(group) { case 0: if(SetCtrlAttribute (panel, XPS_PANEL_XPS_XX, ATTR_CTRL_VAL, position[0] ) < 0) xps_c8ui_error("Problem setting distance X"); if(SetCtrlAttribute (panel, XPS_PANEL_XPS_XX_2, ATTR_CTRL_VAL, position[1] ) < 0) xps_c8ui_error("Problem setting distance X"); printf("\n Move XX done"); break; case 1: if(SetCtrlAttribute (panel, XPS_PANEL_XPS_YY, ATTR_CTRL_VAL, position[0] ) < 0) xps_c8ui_error("Problem setting distance Y"); if(SetCtrlAttribute (panel, XPS_PANEL_XPS_YY_2, ATTR_CTRL_VAL, position[1] ) < 0) xps_c8ui_error("Problem setting distance Y"); printf("\n Move YY done"); break; } } return 0; }