00001
00005 #include <stdio.h>
00006 #include <bpm/bpm_messages.h>
00007 #include <bpm/bpm_process.h>
00008
00019 int process_diode( bpmconf_t *bpm, bpmsignal_t *sig, bpmproc_t *proc ) {
00020
00021 double t0;
00022 char msg[128];
00023
00024 if ( ! bpm || ! sig || ! proc ) {
00025 bpm_error( "Invalid pointer arguments in process_diode(...)",
00026 __FILE__, __LINE__ );
00027 return BPM_FAILURE;
00028 }
00029
00030
00031 if ( bpm->cav_type != diode ) {
00032 bpm_error( "Invalid configuration type in process_diode(...)",
00033 __FILE__, __LINE__ );
00034 return BPM_FAILURE;
00035 }
00036
00037 if ( sig->wf ) {
00038 if( fit_diodepulse( sig->wf, bpm->digi_nsamples, bpm->digi_freq, &t0 ) == BPM_FAILURE ) {
00039 bpm_error( "Could not fit the diode pulse in process_diode(...)",
00040 __FILE__, __LINE__ );
00041 return BPM_FAILURE;
00042 } else {
00043
00044 proc->t0 = t0;
00045 }
00046 } else {
00047 sprintf( msg, "Invalid signal pointer for %s in process_diode(...)", bpm->name );
00048 bpm_error( msg, __FILE__, __LINE__ );
00049 return BPM_FAILURE;
00050 }
00051
00052 return BPM_SUCCESS;
00053 }
00054
00055