diff options
-rw-r--r-- | device-functions.c | 14 | ||||
-rw-r--r-- | error_utils.c | 27 | ||||
-rw-r--r-- | globals.h | 2 |
3 files changed, 35 insertions, 8 deletions
diff --git a/device-functions.c b/device-functions.c index b9fdb0f..25814c1 100644 --- a/device-functions.c +++ b/device-functions.c @@ -1350,14 +1350,26 @@ static void stop_gate_override () int Set_zout(int channel,int setting,int really_for_zout) { + int error_num; + int i; + int update_zout_slowly; + update_zout_slowly=NO; /* abandon if high channel selected by user but not enabled by firmware */ if (channel && !globals.Flash.ChanKey_zout) { return InvalidChannel; } - update_zout_slowly=NO; + if (really_for_zout) { + for (i=0; i<max_channels; ++i) { + TestState[i]=globals.ChannelState[i]; + } + TestState[channel].zout=setting; + if ((error_num=Error_check(TestState))) { + return error_num; + } + } /* The Zout hardware and software is controlled by PW commands in the AVPP. */ /* This mode is signalled by really_for_zout=0 */ 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 --- */ @@ -884,7 +884,7 @@ typedef struct { float err_max_slew[max_channels]; float err_min_load_type[max_channels]; float err_max_load_type[max_channels]; - float err_max_zout[max_channels]; + int err_max_zout[max_channels]; float composite_min_burst_time[max_channels]; /* minimum ever possible gap, taking into account all constraints */ } ConstraintsStruct; |