/* ************************************************************* */ /* INCLUDE FILES */ #include #include #include #include #include "vtcoil.h" #include "vtcoilparam.h" #include "vtcoilui.h" #include "blhar.h" #include "blharparam.h" #include "blharui.h" /* ************************************************************* */ /* PRIVATE FUNCTIONS */ void blharop_init(void); void blharop_meas(void); void blharop_exit(void); /* ************************************************************* */ int main(int argc, char *argv[]) { /* Perform all initialization for the program */ blharop_init(); /* Do a BL harmonics measurement */ blharop_meas(); /* Run the user interface */ //RunUserInterface (); /* Exit all systems */ blharop_exit(); /* Message */ printf("\nDone\n"); /* Done */ return 0; } /* ************************************************************** */ void blharop_init(void) { /* Declare variables */ FILE* file_ptr; char log_file[80]; char str_dat_file[80]; char har_dat_file[80]; char str_plt_file[80]; char har_plt_file[80]; struct vtcoil_param_struct vtcoil_param; struct blhar_param_struct blhar_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 magnet strength dat file */ strcpy(str_dat_file, "strdat.ru1"); file_ptr = fopen (str_dat_file, "w"); if (file_ptr == NULL) return; fclose(file_ptr); /* Initialize the harmonics dat file */ strcpy(har_dat_file, "hardat.ru1"); file_ptr = fopen (har_dat_file, "w"); if (file_ptr == NULL) return; fclose(file_ptr); /* Initialize the magnet strength plt file */ strcpy(str_plt_file, "strplt.ru1"); file_ptr = fopen (str_plt_file, "w"); if (file_ptr == NULL) return; fclose(file_ptr); /* Initialize the harmonics plt file */ strcpy(har_plt_file, "harplt.ru1"); file_ptr = fopen (har_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 */ vtcoilparam_fill_param_struct(&vtcoil_param); /* Initialize the integrated voltage system */ vtcoil_init(log_file, vtcoil_param); vtcoilui_init(25, 25, vtcoil_param); vtcoil_locate_index(); /* Get BL harmonics parameters */ blharparam_fill_param_struct(&blhar_param); /* Initialize the BL harmonics module */ blhar_init(log_file, str_dat_file, har_dat_file, str_plt_file, har_plt_file, blhar_param); blharui_init(25, 400, blhar_param); /* Done */ return; } /* ************************************************************* */ void blharop_meas(void) { /* Declare all variables */ struct blhar_data_struct blhar_data; double magnet_current_ave; double magnet_current_rms; int num_str_har; double sl_ave, sl_rms; double th_ave, th_rms; /* Do a magnet strength measurement */ blhar_get_str_ave(&num_str_har, &sl_ave, &sl_rms, &th_ave, &th_rms); /* Write the results to the data file */ blhar_dat_str_ave(num_str_har, magnet_current_ave, magnet_current_rms, sl_ave, sl_rms, th_ave, th_rms); /* Write the results to the plot file */ blhar_plt_str_ave(num_str_har, magnet_current_ave, magnet_current_rms, sl_ave, sl_rms, th_ave, th_rms); /* Do a BL harmonics measurement */ blhar_get_blhar_ave(&blhar_data); /* Write the results to the data file */ magnet_current_ave = 100.; magnet_current_rms = 5.; blhar_dat_blhar_ave(magnet_current_ave, magnet_current_rms, blhar_data); /* Write the results to the plot file */ blhar_plt_blhar_ave("First Measurement", blhar_data); blhar_plt_blhar_ave("Second Measurement", blhar_data); /* Done */ return; } /* ************************************************************** */ void blharop_exit(void) { /* Exit the VTcoil system */ vtcoil_exit(); /* Done */ return; }