diff options
Diffstat (limited to 'error_utils.c')
-rw-r--r-- | error_utils.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/error_utils.c b/error_utils.c index 22f469e..ccd9837 100644 --- a/error_utils.c +++ b/error_utils.c @@ -673,6 +673,16 @@ void check_initial_max_value (float test_limit, float *running_limit, float prop } } + +void check_initial_max_value_int (int test_limit, int *running_limit, int proposed_value, int possible_error, int *actual_error) { + *running_limit = test_limit; + + if ( proposed_value > *running_limit) { + *actual_error = possible_error; + } +} + + void check_another_max_value (float test_limit, float *running_limit, float proposed_value, int possible_error, int *actual_error) { if (test_limit < *running_limit) { check_initial_max_value (test_limit, running_limit, proposed_value, possible_error, actual_error); @@ -680,6 +690,12 @@ void check_another_max_value (float test_limit, float *running_limit, float prop } +void check_another_max_value_int (int test_limit, int *running_limit, int proposed_value, int possible_error, int *actual_error) { + if (test_limit < *running_limit) { + check_initial_max_value_int (test_limit, running_limit, proposed_value, possible_error, actual_error); + } +} + int Error_check(ChannelStruct ChannelStateToTest[max_channels]) { @@ -870,7 +886,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) // for -LV option, restrict power dissipated in internal attenuators if (globals.Flash.switchable_zout[i] && - (globals.ChannelState[i].zout==globals.Flash.zout_max[i]) && + (ChannelStateToTest[i].zout==globals.Flash.zout_max[i]) && (globals.Flash.switchable_zout_max_duty[i] > 0.0) && (max_duty_this_ampl > globals.Flash.switchable_zout_max_duty[i])) { max_duty_this_ampl = globals.Flash.switchable_zout_max_duty[i]; @@ -1390,14 +1406,13 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) } /* --- check zout / duty settings --- */ - - check_initial_max_value (globals.Flash.zout_max[i], &globals.Constraints.err_max_zout[i], ChannelStateToTest[i].zout, max_zout_error, &report_error); + check_initial_max_value_int (globals.Flash.zout_max[i], &globals.Constraints.err_max_zout[i], ChannelStateToTest[i].zout, max_zout_error, &report_error); if (globals.Flash.switchable_zout[i] && - (globals.ChannelState[i].zout==globals.Flash.zout_max[i]) && + (ChannelStateToTest[i].zout==globals.Flash.zout_max[i]) && (globals.Flash.switchable_zout_max_duty[i] > 0.0) && - (duty_cycle > (globals.Flash.switchable_zout_max_duty[i] / duty_scale))) { + (duty_cycle > (globals.Flash.switchable_zout_max_duty[i] * 100.0 / duty_scale))) { // can only operate at min Zout at high duty cycles, due to attenuator limits - check_another_max_value (globals.Flash.zout_min[i], &globals.Constraints.err_max_zout[i], ChannelStateToTest[i].zout, max_zout_duty_error, &report_error); + check_another_max_value_int (globals.Flash.zout_min[i], &globals.Constraints.err_max_zout[i], ChannelStateToTest[i].zout, max_zout_duty_error, &report_error); } /* --- check resistance settings --- */ |