/* ************************************************************** */ /* * Module VCOILUI * This module contains functions for the VCOIL * user interface. * * Zachary Wolf * 10/9/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vcoil.h" #include "vcoilui.h" #include "vcoiluir.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vcoil_panel; static struct vcoil_param_struct vcoil_param; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void vcoilui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vcoilui_init * This function initializes the user interface for VCOIL. * * Zachary Wolf * 10/9/02 */ void vcoilui_init(struct vcoil_param_struct vcoil_param_in) { /* Save the parameters */ vcoil_param = vcoil_param_in; /* Open the VCOIL panel */ vcoil_panel = LoadPanel(0, "vcoiluir.uir", VCOILPAN); if (vcoil_panel < 0) { vcoilui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(vcoil_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vcoilui_error * This function handles error messages for the VCOIL user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 10/9/02 */ void vcoilui_error(char* message) { /* Declare variables */ char buf[VCOIL_MAX_CMD]; /* Notify the operator of the error */ printf("\nVCOILUI 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, VCOIL_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK vcoilui_measure(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int har_num; double freq; double meas_v_amp, meas_v_ph; double v_amp, v_ph; switch (event) { case EVENT_COMMIT: vcoil_get_coil_rot_freq(&freq); SetCtrlVal(vcoil_panel, VCOILPAN_NUM_FREQ, freq); GetCtrlVal(vcoil_panel, VCOILPAN_NUM_HAR_NUM, &har_num); vcoil_get_vn_coil_raw(har_num, &meas_v_amp, &meas_v_ph); v_amp = meas_v_amp * 1.4142136; /* rms -> 0 to peak */ v_ph = meas_v_ph - 90.; /* cosine convention */ if (v_ph < -180.) v_ph = v_ph + 360.; if (v_ph > 180.) v_ph = v_ph - 360.; SetCtrlVal(vcoil_panel, VCOILPAN_NUM_MEAS_V_AMP, meas_v_amp); SetCtrlVal(vcoil_panel, VCOILPAN_NUM_MEAS_V_PH, meas_v_ph); SetCtrlVal(vcoil_panel, VCOILPAN_NUM_V_AMP, v_amp); SetCtrlVal(vcoil_panel, VCOILPAN_NUM_V_PH, v_ph); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK vcoilui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vcoil_exit(); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }