/* ************************************************************** */ /* * Module BTCOILUI * This module contains functions for the IOtech BTCOIL * user interface. * * Zachary Wolf * 1/12/00 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "btcoil.h" #include "btcoilui.h" #include "btcoiluir.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int btcoil_panel; static struct btcoil_param_struct btcoil_param; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void btcoilui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * btcoilui_init * This function initializes the user interface for BTCOIL. * * Zachary Wolf * 8/3/98 */ void btcoilui_init(struct btcoil_param_struct btcoil_param_in) { /* Save the parameters */ btcoil_param = btcoil_param_in; /* Open the BTCOIL panel */ btcoil_panel = LoadPanel(0, "btcoiluir.uir", BTCOILPAN); if (btcoil_panel < 0) { btcoilui_error("Could not open user interface panel"); return; } /* Display the panel when the user interface runs */ DisplayPanel(btcoil_panel); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * btcoilui_error * This function handles error messages for the BTCOIL user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 8/3/98 */ void btcoilui_error(char* message) { /* Declare variables */ char buf[BTCOIL_MAX_CMD]; /* Notify the operator of the error */ printf("\nBTCOILUI 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, BTCOIL_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK btcoilui_measure(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double meas_freq, meas_v_amp, meas_v_ph; double freq, v_amp, v_ph; double Bt, th; switch (event) { case EVENT_COMMIT: btcoil_get_v_coil_raw(&meas_freq, &meas_v_amp, &meas_v_ph); btcoil_get_v_coil(&freq, &v_amp, &v_ph); btcoil_calc_Bt(freq, v_amp, v_ph, &Bt, &th); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_MEAS_FREQ, meas_freq); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_MEAS_V_AMP, meas_v_amp); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_MEAS_V_PH, meas_v_ph); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_FREQ, freq); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_V_AMP, v_amp); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_V_PH, v_ph); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_Bt_G, Bt * 10000.); SetCtrlVal(btcoil_panel, BTCOILPAN_NUM_TH_sp, th); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK btcoilui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: btcoil_exit(); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }