/* ************************************************************* */ /* INCLUDE FILES */ #include #include #include #include #include #include "vtwire.h" #include "vtwireparam.h" #include "vtwireui.h" #include "blwire.h" #include "blwireui.h" #include "blwireparam.h" /* ************************************************************* */ /* PRIVATE FUNCTIONS */ void blwireop_init(void); void blwireop_meas(void); void blwireop_exit(void); /* ************************************************************* */ int main(int argc, char *argv[]) { /* Perform all initialization for the program */ blwireop_init(); /* Do a BL harmonics measurement */ blwireop_meas(); /* Run the user interface */ RunUserInterface (); /* Exit all systems */ blwireop_exit(); /* Message */ printf("\nDone\n"); /* Done */ return 0; } /* ************************************************************** */ void blwireop_init(void) { /* Declare variables */ FILE* file_ptr; char log_file[80]; char dat_file[80]; char plt_file[80]; struct vtwire_param_struct vtwire_param; struct blwire_param_struct blwire_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 /* Get VTcoil parameters */ vtwireparam_fill_param_struct(&vtwire_param); /* Initialize the integrated voltage system */ vtwire_init(log_file, vtwire_param); vtwireui_init(25, 25, vtwire_param); /* Get BL harmonics parameters */ blwireparam_fill_param_struct(&blwire_param); /* Initialize the BL harmonics module */ blwire_init(log_file, dat_file, plt_file, blwire_param); if (blwire_param.show_ui == BLWIRE_TRUE) blwireui_init(25, 400, blwire_param); /* Done */ return; } /* ************************************************************* */ void blwireop_meas(void) { /* Declare all variables */ int i; int num_str_har; int num_x0_pos; double x0[10]; double bl_ave[10], bl_rms[10]; double gauss_noise[10]; double sl_ave, sl_rms; double imag_ave, imag_rms; /* Test the magnet strength calculation */ //num_str_har = 1; //num_x0_pos = 1; //x0[0] = 0.; //bl_ave[0] = 5.; //bl_rms[0] = 1.; num_str_har = 2; num_x0_pos = 5; x0[0] = -2.; x0[1] = -1.; x0[2] = 0.; x0[3] = 1.; x0[4] = 2.; GaussNoise(5, .01, 5, gauss_noise); bl_ave[0] = -4. + gauss_noise[0]; bl_ave[1] = -2. + gauss_noise[1]; bl_ave[2] = 0. + gauss_noise[2]; bl_ave[3] = 2. + gauss_noise[3]; bl_ave[4] = 4. + gauss_noise[4]; bl_rms[0] = .01; bl_rms[1] = .01; bl_rms[2] = .01; bl_rms[3] = .01; bl_rms[4] = .01; for (i = 0; i < num_x0_pos; i++) blwireui_update_meas(x0[i], bl_ave[i], bl_rms[i]); blwire_calc_integ_str(num_str_har, num_x0_pos, x0, bl_ave, bl_rms, &sl_ave, &sl_rms); /* Write the results to the data file */ imag_ave = 100.; imag_rms = 1.; blwire_dat_integ_str_vs_imag(num_str_har, imag_ave, imag_rms, sl_ave, sl_rms); /* Write the results to the plot file */ blwire_plt_integ_str_vs_imag(num_str_har, imag_ave, imag_rms, sl_ave, sl_rms); /* Done */ return; } /* ************************************************************** */ void blwireop_exit(void) { /* Exit the VTcoil system */ vtwire_exit(); /* Done */ return; }