/* ************************************************************** */ /* * Module CM2100UI * This module contains functions for the Compumotor CM2100 * user interface. * * Zachary Wolf * 8/26/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "cm2100uir.h" #include "cm2100ui.h" #include "cm2100.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int cm2100_ID; static int cm2100_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void cm2100ui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * cm2100ui_init * This function initializes the user interface for the CM2100. * * Input: * ID, CM2100 device identifier * * Zachary Wolf * 8/26/98 */ void cm2100ui_init(int ID) { /* Save the device ID */ cm2100_ID = ID; /* Open the CM2100 panel */ cm2100_panel = LoadPanel(0, "cm2100uir.uir", CM2100PAN); if (cm2100_panel < 0) { cm2100ui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(cm2100_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * cm2100ui_error * This function handles error messages for the CM2100 user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/26/98 */ void cm2100ui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nCM2100UI 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 cm2100ui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: cm2100_exit(cm2100_ID); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK cm2100ui_move(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double acc, vel, dis; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, CM2100PAN_NUM_ACCELERATION, &acc); GetCtrlVal(panel, CM2100PAN_NUM_VELOCITY, &vel); GetCtrlVal(panel, CM2100PAN_NUM_DISTANCE, &dis); cm2100_rel_move(cm2100_ID, acc, vel, dis); break; } return 0; } /* ************************************************************** */ int CVICALLBACK cm2100ui_get_position(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; switch (event) { case EVENT_COMMIT: cm2100_get_abs_position(cm2100_ID, &pos); SetCtrlVal(panel, CM2100PAN_NUM_POSITION, pos); break; } return 0; } /* ************************************************************** */ int CVICALLBACK cm2100ui_zero(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double pos; switch (event) { case EVENT_COMMIT: cm2100_zero(cm2100_ID); cm2100_get_abs_position(cm2100_ID, &pos); SetCtrlVal(panel, CM2100PAN_NUM_POSITION, pos); break; case EVENT_RIGHT_CLICK: break; } return 0; }