00001
00005 #include <bpm/bpm_messages.h>
00006 #include <bpm/bpm_calibration.h>
00007
00008 int load_calibration( char *fname, bpmconf_t *bpm, bpmcalib_t *cal, int num_bpms ) {
00009
00010 if ( ! cal || ! fname ) {
00011 bpm_error( "Invalid pointer arguments in calibrate(...)",
00012 __FILE__, __LINE__ );
00013 return BPM_FAILURE;
00014 }
00015
00016 int i;
00017
00018
00019 FILE *f = fopen( fname, "r" );
00020 if ( ! f ) {
00021 char buf[255];
00022 printf("Unable to load calibration \"%s\" in load_calibration(...)", fname );
00023 bpm_error( buf, __FILE__, __LINE__ );
00024 return BPM_FAILURE;
00025 }
00026
00027 char line[255];
00028 char *tok;
00029 int idx;
00030
00031 for (i = 0; i < num_bpms; i++) {
00032 fgets( line, 255, f );
00033
00034 tok = strtok( line, " " );
00035 idx = atoi( strtok( NULL, " " ) );
00036
00037 cal[idx].freq = atof( strtok( NULL, " " ) );
00038 cal[idx].tdecay = atof( strtok( NULL, " " ) );
00039 cal[idx].ddcfiltBW = atof( strtok( NULL, " " ) );
00040 cal[idx].ddcepsFilt = atof( strtok( NULL, " " ) );
00041 cal[idx].t0Offset = atof( strtok( NULL, " " ) );
00042 cal[idx].IQphase = atof( strtok( NULL, " " ) );
00043 cal[idx].posscale = atof( strtok( NULL, " " ) );
00044 cal[idx].slopescale = atof( strtok( NULL, " " ) );
00045 }
00046
00047 return BPM_SUCCESS;
00048 }
00049
00050