/* ************************************************************* */ /* INCLUDE FILES */ #include #include #include #include #include #include "vtscan.h" #include "vtscanparam.h" #include "vtscanui.h" #include "blscan.h" #include "blscanui.h" #include "blscanparam.h" /* ************************************************************* */ /* PRIVATE FUNCTIONS */ void blscanop_init(void); void blscanop_meas(void); void blscanop_exit(void); /* ************************************************************* */ int main(int argc, char *argv[]) { /* Perform all initialization for the program */ blscanop_init(); /* Do a BL harmonics measurement */ blscanop_meas(); /* Run the user interface */ RunUserInterface (); /* Exit all systems */ blscanop_exit(); /* Message */ printf("\nDone\n"); /* Done */ return 0; } /* ************************************************************** */ void blscanop_init(void) { /* Declare variables */ FILE* file_ptr; char log_file[80]; char dat_file[80]; char plt_file[80]; struct vtscan_param_struct vtscan_param; struct blscan_param_struct blscan_param; /* Initialize the log file */ strcpy(log_file, "logfile.ru1"); file_ptr = fopen (log_file, "w"); if (file_ptr == NULL) return; fclose(file_ptr); /* Initialize the dat file */ strcpy(dat_file, "datfile.ru1"); file_ptr = fopen (dat_file, "w"); if (file_ptr == NULL) return; fclose(file_ptr); /* Initialize the plt file */ strcpy(plt_file, "pltfile.ru1"); file_ptr = fopen (plt_file, "w"); if (file_ptr == NULL) return; fclose(file_ptr); /* Initialize the GPIB system */ /* But do it only if the hardware is present */ #ifndef DUMMY_DEVICES //board = ibfind("GPIB0"); //ibsic(board); #endif /* Initialize the VTscan system */ vtscanparam_fill_param_struct(&vtscan_param); vtscan_init(log_file, vtscan_param); vtscanui_init(25, 400, vtscan_param); /* Initialize the BLscan module */ blscanparam_fill_param_struct(&blscan_param); blscan_init(log_file, dat_file, plt_file, blscan_param); if (blscan_param.show_ui == BLSCAN_TRUE) blscanui_init(25, 25, blscan_param); /* Done */ return; } /* ************************************************************* */ void blscanop_meas(void) { /* Declare all variables */ int i; int num_samp; double x[101]; double x_norm[101]; double vt[101]; int order; double vt_coeff[20]; double vt_fit[101]; double x0, dx; int num_har; double aln[20]; double bln[20]; double bln_ave[20]; double bln_rms[20]; double imag_ave, imag_rms; /* Test the sampling */ //x0 = -.05; //dx = .1; //num_samp = 50; //blscan_get_vt(x0, dx, num_samp, x, vt); /* Test the VT polynomial coefficient calculations */ num_samp = 100; for (i = 0; i <= 100; i++) x[i] = (double) (i - 50) * .001; for (i = 0; i <= 100; i++) vt[i] = x[i]/.05 + pow(x[i]/.05, 2) + pow(x[i]/.05, 3); order = 10; num_har = 10; blscan_calc_vt_coeff(num_samp, x, vt, order, x_norm, vt_coeff, vt_fit); blscan_calc_bln_wire(order, vt_coeff, num_har, bln_ave); /* Test the get_BLn function */ //num_har = 10; imag_ave = 100.; imag_rms = .1; //blscan_get_bln_ave(BLSCAN_WIRE, num_har, bln_ave, bln_rms); blscan_dat_bln_config_ave(BLSCAN_WIRE, imag_ave, imag_rms, num_har, bln_ave, bln_rms); //blscan_plt_bln_ave(imag_ave, imag_rms, num_har, bln_ave, bln_rms); /* Done */ return; } /* ************************************************************** */ void blscanop_exit(void) { /* Exit the VTcoil system */ vtscan_exit(); /* Done */ return; }