diff options
Diffstat (limited to 'error_utils.c')
-rw-r--r-- | error_utils.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/error_utils.c b/error_utils.c index 6f9d85c..14b7684 100644 --- a/error_utils.c +++ b/error_utils.c @@ -81,11 +81,11 @@ void queue_error(int error_num) } set_gpib_error_flags (error_num); - if (globals.number_of_errors<error_queue_length) { - ++globals.number_of_errors; - globals.error_queue[globals.number_of_errors]=error_num; + if (globals.Errors.number_of_errors<error_queue_length) { + ++globals.Errors.number_of_errors; + globals.Errors.error_queue[globals.Errors.number_of_errors]=error_num; } else { - globals.error_queue[globals.number_of_errors]=queue_overflow; + globals.Errors.error_queue[globals.Errors.number_of_errors]=queue_overflow; } return; @@ -154,10 +154,10 @@ void queue_and_broadcast_sensor_alarm(int error_num) void Error_Remove_From_Queue(void) { int i; - for (i=1; i<globals.number_of_errors; ++i) { - globals.error_queue[i]=globals.error_queue[i+1]; + for (i=1; i<globals.Errors.number_of_errors; ++i) { + globals.Errors.error_queue[i]=globals.Errors.error_queue[i+1]; } - --globals.number_of_errors; /* error reported, so remove it from the error queue */ + --globals.Errors.number_of_errors; /* error reported, so remove it from the error queue */ } @@ -628,14 +628,14 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) for (i=0; i<num_of_chan; ++i) { /* Must be changing a setting */ - globals.last_activity_at[i] = sec_timer (); + globals.Timers.last_activity_at[i] = sec_timer (); /* ignore errors if it is in programming mode */ if (globals.Flash.fully_programmed != All_Programmed) { return OK; } - if (globals.do_check_settings==NO) { + if (globals.Flags.do_check_settings==NO) { return OK; } @@ -645,7 +645,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) } if (ChannelStateToTest[i].pw<smallest_allowed_number - && globals.Flash.min_pw[i]>0.0) { + && globals.Flash.min_pw[i]>0.0) { return pw_lower_limit; } @@ -662,14 +662,14 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) } if (globals.Flash.duty_ampl_mid1[i]>0.0 && - (fabs(ChannelStateToTest[i].amplitude)<= globals.Flash.duty_ampl_mid1[i]) && - (globals.Flash.max_duty_mid1[i] > max_duty_this_ampl)) { + (fabs(ChannelStateToTest[i].amplitude)<= globals.Flash.duty_ampl_mid1[i]) && + (globals.Flash.max_duty_mid1[i] > max_duty_this_ampl)) { max_duty_this_ampl = globals.Flash.max_duty_mid1[i]; } if (globals.Flash.duty_ampl_mid2[i]>0.0 && - (fabs(ChannelStateToTest[i].amplitude)<= globals.Flash.duty_ampl_mid2[i]) && - (globals.Flash.max_duty_mid2[i] > max_duty_this_ampl)) { + (fabs(ChannelStateToTest[i].amplitude)<= globals.Flash.duty_ampl_mid2[i]) && + (globals.Flash.max_duty_mid2[i] > max_duty_this_ampl)) { max_duty_this_ampl = globals.Flash.max_duty_mid2[i]; } @@ -690,8 +690,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) duty_scale = 200.0; } if ( (ChannelStateToTest[i].burst_count>1) - && (globals.Flash.max_burst_count[i]>1) - && !globals.Flash.burst_func[i]) { + && (globals.Flash.max_burst_count[i]>1) + && !globals.Flash.burst_func[i]) { duty_scale *= (float) ChannelStateToTest[i].burst_count; } @@ -745,8 +745,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) } if ( (ChannelStateToTest[i].burst_count>1) - && (globals.Flash.max_burst_count[i]>1) - && !globals.Flash.burst_func[i]) { + && (globals.Flash.max_burst_count[i]>1) + && !globals.Flash.burst_func[i]) { temp=1/(ChannelStateToTest[i].burst_count * (ChannelStateToTest[i].pw+ChannelStateToTest[i].burst_time)); if (temp<globals.Constraints.err_max_freq[i]) { globals.Constraints.err_max_freq[i]=temp; @@ -806,7 +806,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_min_pw[i]=globals.Flash.min_pw[i]; if ( (globals.Constraints.err_min_pw[i]>=0.0 && ChannelStateToTest[i].pw<(0.999*globals.Constraints.err_min_pw[i])) - || (globals.Constraints.err_min_pw[i]<0.0 && ChannelStateToTest[i].pw<(1.001*globals.Constraints.err_min_pw[i])) ) { + || (globals.Constraints.err_min_pw[i]<0.0 && ChannelStateToTest[i].pw<(1.001*globals.Constraints.err_min_pw[i])) ) { report_error=pw_lower_limit; } @@ -862,8 +862,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) } if ( (ChannelStateToTest[i].burst_count>1) - && (globals.Flash.max_burst_count[i]>1) - && !globals.Flash.burst_func[i]) { + && (globals.Flash.max_burst_count[i]>1) + && !globals.Flash.burst_func[i]) { temp=(1/ChannelStateToTest[i].frequency)/ChannelStateToTest[i].burst_count - ChannelStateToTest[i].burst_time; if (temp<globals.Constraints.err_max_pw[i]) { globals.Constraints.err_max_pw[i]=temp; @@ -932,7 +932,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) } if ( (globals.Constraints.err_min_delay[i]>=0.0 && ChannelStateToTest[i].delay<(0.999*globals.Constraints.err_min_delay[i])) - || (globals.Constraints.err_min_delay[i]<0.0 && ChannelStateToTest[i].delay<(1.001*globals.Constraints.err_min_delay[i])) ) { + || (globals.Constraints.err_min_delay[i]<0.0 && ChannelStateToTest[i].delay<(1.001*globals.Constraints.err_min_delay[i])) ) { report_error=delay_lower_limit; } @@ -941,7 +941,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp>globals.Constraints.err_min_delay[i]) { globals.Constraints.err_min_delay[i]=temp; if ( (globals.Constraints.err_min_delay[i]>=0.0 && ChannelStateToTest[i].delay<(0.999*globals.Constraints.err_min_delay[i])) - || (globals.Constraints.err_min_delay[i]<0.0 && ChannelStateToTest[i].delay<(1.001*globals.Constraints.err_min_delay[i])) ) { + || (globals.Constraints.err_min_delay[i]<0.0 && ChannelStateToTest[i].delay<(1.001*globals.Constraints.err_min_delay[i])) ) { report_error=Delay_Exceeds_95Period; } } @@ -952,7 +952,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp>globals.Constraints.err_min_delay[i]) { globals.Constraints.err_min_delay[i]=temp; if ( (globals.Constraints.err_min_delay[i]>=0.0 && ChannelStateToTest[i].delay<(0.999*globals.Constraints.err_min_delay[i])) - || (globals.Constraints.err_min_delay[i]<0.0 && ChannelStateToTest[i].delay<(1.001*globals.Constraints.err_min_delay[i])) ) { + || (globals.Constraints.err_min_delay[i]<0.0 && ChannelStateToTest[i].delay<(1.001*globals.Constraints.err_min_delay[i])) ) { report_error=PW_Exceeds_Double_Separation; } } @@ -963,7 +963,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_max_delay[i]=globals.Flash.max_delay[i]; if ( (globals.Constraints.err_max_delay[i]>=0.0 && ChannelStateToTest[i].delay>(1.001*globals.Constraints.err_max_delay[i])) - || (globals.Constraints.err_max_delay[i]<0.0 && ChannelStateToTest[i].delay>(0.999*globals.Constraints.err_max_delay[i])) ) { + || (globals.Constraints.err_max_delay[i]<0.0 && ChannelStateToTest[i].delay>(0.999*globals.Constraints.err_max_delay[i])) ) { report_error=delay_upper_limit; } @@ -972,7 +972,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp<globals.Constraints.err_max_delay[i]) { globals.Constraints.err_max_delay[i]=temp; if ( (globals.Constraints.err_max_delay[i]>=0.0 && ChannelStateToTest[i].delay>(1.001*globals.Constraints.err_max_delay[i])) - || (globals.Constraints.err_max_delay[i]<0.0 && ChannelStateToTest[i].delay>(0.999*globals.Constraints.err_max_delay[i])) ) { + || (globals.Constraints.err_max_delay[i]<0.0 && ChannelStateToTest[i].delay>(0.999*globals.Constraints.err_max_delay[i])) ) { report_error=Delay_Exceeds_95Period; } } @@ -982,7 +982,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp<globals.Constraints.err_max_delay[i]) { globals.Constraints.err_max_delay[i]=temp; if ( (globals.Constraints.err_max_delay[i]>=0.0 && ChannelStateToTest[i].delay>(1.001*globals.Constraints.err_max_delay[i])) - || (globals.Constraints.err_max_delay[i]<0.0 && ChannelStateToTest[i].delay>(0.999*globals.Constraints.err_max_delay[i])) ) { + || (globals.Constraints.err_max_delay[i]<0.0 && ChannelStateToTest[i].delay>(0.999*globals.Constraints.err_max_delay[i])) ) { report_error=Double_Separation_Too_Large; } } @@ -991,7 +991,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* ------------------------------- */ /* disable amplitude checks if amplitude calibration is in progress */ - if (!globals.extended_ampl_min_max) { + if (!globals.Flags.extended_ampl_min_max) { globals.Constraints.err_max_vcc1[i]=globals.Flash.vcc1_max[i]; globals.Constraints.err_max_vcc2[i]=globals.Flash.vcc2_max[i]; @@ -1023,7 +1023,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_min_ampl[i]=globals.Flash.min_ampl[i]; if ( (globals.Constraints.err_min_ampl[i]>=0.0 && ChannelStateToTest[i].amplitude<(0.999*globals.Constraints.err_min_ampl[i])) - || (globals.Constraints.err_min_ampl[i]<0.0 && ChannelStateToTest[i].amplitude<(1.001*globals.Constraints.err_min_ampl[i])) ) { + || (globals.Constraints.err_min_ampl[i]<0.0 && ChannelStateToTest[i].amplitude<(1.001*globals.Constraints.err_min_ampl[i])) ) { report_error=amplitude_lower_limit; } @@ -1031,7 +1031,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp>globals.Constraints.err_min_ampl[i]) { globals.Constraints.err_min_ampl[i]=temp; if ( (globals.Constraints.err_min_ampl[i]>=0.0 && ChannelStateToTest[i].amplitude<(0.999*globals.Constraints.err_min_ampl[i])) - || (globals.Constraints.err_min_ampl[i]<0.0 && ChannelStateToTest[i].amplitude<(1.001*globals.Constraints.err_min_ampl[i])) ) { + || (globals.Constraints.err_min_ampl[i]<0.0 && ChannelStateToTest[i].amplitude<(1.001*globals.Constraints.err_min_ampl[i])) ) { report_error=ampl_plus_os_lower_limit; } } @@ -1043,8 +1043,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (globals.Flash.ampl_min_max_only[i]) if ( !(fabs(ChannelStateToTest[i].amplitude - globals.Flash.min_ampl[i] ) < globals.Flash.ampl_zero_equiv[i] ) - && - !(fabs(ChannelStateToTest[i].amplitude - globals.Flash.max_ampl[i]) < globals.Flash.ampl_zero_equiv[i] ) + && + !(fabs(ChannelStateToTest[i].amplitude - globals.Flash.max_ampl[i]) < globals.Flash.ampl_zero_equiv[i] ) ) { @@ -1057,7 +1057,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- check maximum amplitude --- */ globals.Constraints.err_max_ampl[i]=globals.Flash.max_ampl[i]; if ( (globals.Constraints.err_max_ampl[i]>=0.0 && ChannelStateToTest[i].amplitude>(1.001*globals.Constraints.err_max_ampl[i])) - || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) { + || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) { report_error=amplitude_upper_limit; } @@ -1091,7 +1091,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp<globals.Constraints.err_max_ampl[i]) { globals.Constraints.err_max_ampl[i]=temp; if ( (globals.Constraints.err_max_ampl[i]>=0.0 && ChannelStateToTest[i].amplitude>(1.001*globals.Constraints.err_max_ampl[i])) - || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) { + || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) { report_error=ampl_plus_os_upper_limit; } } @@ -1103,7 +1103,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp<globals.Constraints.err_max_ampl[i]) { globals.Constraints.err_max_ampl[i]=temp; if ( (globals.Constraints.err_max_ampl[i]>=0.0 && ChannelStateToTest[i].amplitude>(1.001*globals.Constraints.err_max_ampl[i])) - || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) { + || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) { report_error=Average_Amplitude_Too_High; } } @@ -1122,9 +1122,9 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp<globals.Constraints.err_max_ampl[i]) { globals.Constraints.err_max_ampl[i]=temp; if ( ( (globals.Constraints.err_max_ampl[i]>=0.0 && ChannelStateToTest[i].amplitude>(1.001*globals.Constraints.err_max_ampl[i])) - || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) + || (globals.Constraints.err_max_ampl[i]<0.0 && ChannelStateToTest[i].amplitude>(0.999*globals.Constraints.err_max_ampl[i])) ) - && (duty_cycle > 1.001*(100.0*max_duty_high_ampl/duty_scale)) + && (duty_cycle > 1.001*(100.0*max_duty_high_ampl/duty_scale)) ) { report_error=duty_cycle_upper_limit; } @@ -1141,7 +1141,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_min_offset[i]=globals.Flash.min_offset[i]; if ( (globals.Constraints.err_min_offset[i]>=0.0 && ChannelStateToTest[i].offset<(0.999*globals.Constraints.err_min_offset[i])) - || (globals.Constraints.err_min_offset[i]<0.0 && ChannelStateToTest[i].offset<(1.001*globals.Constraints.err_min_offset[i])) ) { + || (globals.Constraints.err_min_offset[i]<0.0 && ChannelStateToTest[i].offset<(1.001*globals.Constraints.err_min_offset[i])) ) { report_error=offset_lower_limit; } @@ -1149,7 +1149,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp>globals.Constraints.err_min_offset[i]) { globals.Constraints.err_min_offset[i]=temp; if ( (globals.Constraints.err_min_offset[i]>=0.0 && ChannelStateToTest[i].offset<(0.999*globals.Constraints.err_min_offset[i])) - || (globals.Constraints.err_min_offset[i]<0.0 && ChannelStateToTest[i].offset<(1.001*globals.Constraints.err_min_offset[i])) ) { + || (globals.Constraints.err_min_offset[i]<0.0 && ChannelStateToTest[i].offset<(1.001*globals.Constraints.err_min_offset[i])) ) { report_error=ampl_plus_os_lower_limit; } } @@ -1175,7 +1175,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_max_offset[i]=globals.Flash.max_offset[i]; if ( (globals.Constraints.err_max_offset[i]>=0.0 && ChannelStateToTest[i].offset>(1.001*globals.Constraints.err_max_offset[i])) - || (globals.Constraints.err_max_offset[i]<0.0 && ChannelStateToTest[i].offset>(0.999*globals.Constraints.err_max_offset[i])) ) { + || (globals.Constraints.err_max_offset[i]<0.0 && ChannelStateToTest[i].offset>(0.999*globals.Constraints.err_max_offset[i])) ) { report_error=offset_upper_limit; } @@ -1183,7 +1183,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp<globals.Constraints.err_max_offset[i]) { globals.Constraints.err_max_offset[i]=temp; if ( (globals.Constraints.err_max_offset[i]>=0.0 && ChannelStateToTest[i].offset>(1.001*globals.Constraints.err_max_offset[i])) - || (globals.Constraints.err_max_offset[i]<0.0 && ChannelStateToTest[i].offset>(0.999*globals.Constraints.err_max_offset[i])) ) { + || (globals.Constraints.err_max_offset[i]<0.0 && ChannelStateToTest[i].offset>(0.999*globals.Constraints.err_max_offset[i])) ) { report_error=ampl_plus_os_upper_limit; } } @@ -1208,8 +1208,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- check for nonsensical negatives ------ */ if ( ChannelStateToTest[i].frequency<0.0 - || ((ChannelStateToTest[i].pw<0.0) && (globals.Flash.min_pw[i] > 0.0)) - || ChannelStateToTest[i].zout<0) { + || ((ChannelStateToTest[i].pw<0.0) && (globals.Flash.min_pw[i] > 0.0)) + || ChannelStateToTest[i].zout<0) { report_error=Negative_Not_Allowed; } /* ------------------------------- */ @@ -1222,8 +1222,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- check minimum setting --- */ if ( (!globals.Flash.burst_func[i] && ChannelStateToTest[i].burst_count<1) - || - (globals.Flash.burst_func[i] && ChannelStateToTest[i].burst_count<0)) { + || + (globals.Flash.burst_func[i] && ChannelStateToTest[i].burst_count<0)) { report_error=IllegalParameter; } @@ -1244,7 +1244,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp < (float) globals.Constraints.err_max_burst_count[i]) { globals.Constraints.err_max_burst_count[i] = (int) temp; if ( (ChannelStateToTest[i].burst_count>globals.Constraints.err_max_burst_count[i]) - && (ChannelStateToTest[i].burst_count>1)) { + && (ChannelStateToTest[i].burst_count>1)) { report_error=max_burst_count_error; } } @@ -1256,7 +1256,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp < (float) globals.Constraints.err_max_burst_count[i]) { globals.Constraints.err_max_burst_count[i] = (int) temp; if ( (ChannelStateToTest[i].burst_count>globals.Constraints.err_max_burst_count[i]) - && (ChannelStateToTest[i].burst_count>1)) { + && (ChannelStateToTest[i].burst_count>1)) { report_error=Burst_Exceeds_Period; } } @@ -1267,7 +1267,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_min_burst_time[i]=globals.Flash.min_burst_gap[i]; if ( (ChannelStateToTest[i].burst_count>1) - && (ChannelStateToTest[i].burst_time<(0.999*globals.Constraints.err_min_burst_time[i]))) { + && (ChannelStateToTest[i].burst_time<(0.999*globals.Constraints.err_min_burst_time[i]))) { report_error=min_burst_gap_error; } @@ -1279,7 +1279,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp > globals.Constraints.err_min_burst_time[i]) { globals.Constraints.err_min_burst_time[i] = temp; if ( (ChannelStateToTest[i].burst_count>1) - && (ChannelStateToTest[i].burst_time<(0.999*globals.Constraints.err_min_burst_time[i]))) { + && (ChannelStateToTest[i].burst_time<(0.999*globals.Constraints.err_min_burst_time[i]))) { report_error=min_burst_period_error; } } @@ -1289,7 +1289,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) if (temp > globals.Constraints.err_min_burst_time[i]) { globals.Constraints.err_min_burst_time[i] = temp; if ( (ChannelStateToTest[i].burst_time<(0.999*globals.Constraints.err_min_burst_time[i])) - && (ChannelStateToTest[i].burst_count>1)) { + && (ChannelStateToTest[i].burst_count>1)) { report_error=burst_duty_error; } } @@ -1299,7 +1299,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) globals.Constraints.err_max_burst_time[i]=globals.Flash.max_burst_gap[i]; if ( (ChannelStateToTest[i].burst_count>1) - && (ChannelStateToTest[i].burst_time>(1.001*globals.Constraints.err_max_burst_time[i]))) { + && (ChannelStateToTest[i].burst_time>(1.001*globals.Constraints.err_max_burst_time[i]))) { report_error=max_burst_gap_error; } @@ -1309,7 +1309,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- check rise time settings --- */ /* disable amplitude checks if calibration is in progress */ if (!globals.Flash.fixed_rise_time[i]) - if (!globals.extended_ampl_min_max) { + if (!globals.Flags.extended_ampl_min_max) { globals.Constraints.err_min_rise_time[i]=globals.Flash.min_rise_time[i]; if (ChannelStateToTest[i].rise_time<(0.999*globals.Constraints.err_min_rise_time[i])) { report_error=min_rise_time_error; @@ -1324,7 +1324,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- check slew settings --- */ /* disable amplitude checks if calibration is in progress */ if (globals.Flash.curr_slew[i]) - if (!globals.extended_ampl_min_max) { + if (!globals.Flags.extended_ampl_min_max) { globals.Constraints.err_min_slew[i]=globals.Flash.min_slew[i]; if (ChannelStateToTest[i].slew<(0.999*globals.Constraints.err_min_slew[i])) { report_error=min_slew_error; |