diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | device-functions.c | 27 | ||||
-rw-r--r-- | device-functions.h | 2 | ||||
-rw-r--r-- | error_utils.c | 10 | ||||
-rw-r--r-- | menus.c | 19 |
5 files changed, 39 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 489d476..f9eb8e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ add_definitions(${LIBUSER_CFLAGS}) #add_definitions(${PAM_INCLUDE_DIR}) include_directories(${GLIB_PKG_INCLUDE_DIRS}) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -funsigned-char -Wall -Wno-parentheses") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -funsigned-char -Wall -Wno-parentheses -Wno-deprecated-declarations") add_executable(instr-daemon instr-daemon.c signalobject.c response.c diff --git a/device-functions.c b/device-functions.c index 5fd8a98..c864791 100644 --- a/device-functions.c +++ b/device-functions.c @@ -1719,7 +1719,7 @@ int Set_Amp_Calib(int channel,float meas_ampl) /* use for all channels */ - if (fabs(globals.ChannelState[channel].amplitude)<globals.Flash.ampl_zero_equiv[channel]) { + if (fabs(globals.ChannelState[channel].amplitude) < get_ampl_zero_equiv(channel)) { return NeedNonZeroAmpl; } @@ -2872,12 +2872,12 @@ int Set_VI_Control(int parameter,int channel,float new_ampl) } /* clamping distortion below "zero equiv" amplitude */ - if (ampl_for_distort_calc < globals.Flash.ampl_zero_equiv[channel]) { - ampl_for_distort_calc = globals.Flash.ampl_zero_equiv[channel]; + if (ampl_for_distort_calc < get_ampl_zero_equiv(channel)) { + ampl_for_distort_calc = get_ampl_zero_equiv(channel); } /* prohit values of Y that would cause divide-by-zero error */ - if ( (-globals.Flash.distort_Y[channel]) > globals.Flash.ampl_zero_equiv[channel]) { + if ( (-globals.Flash.distort_Y[channel]) > get_ampl_zero_equiv(channel)) { return PW_Distort_Error; } @@ -4975,7 +4975,7 @@ float rst_ampl_value (int channel) // For AVRQ -AHV, -XHV options, where valids ampls may be // 1.0 to 1.5 kV, positive or negative - return globals.Flash.ampl_zero_equiv[channel]; + return get_ampl_zero_equiv(channel); } else if (max == 0) { @@ -5058,3 +5058,20 @@ void get_min_max_fixed_ampls (int channel, float *min_ampl, float *max_ampl) { if (use_ampl < *min_ampl) *min_ampl = use_ampl; } } + + +float get_ampl_zero_equiv(int channel) +{ + float result; + result = globals.Flash.ampl_zero_equiv[channel]; + + if (globals.Flash.switchable_zout[channel] + && attenuator_count(channel) + && (globals.ChannelState[channel].zout==globals.Flash.zout_max[channel]) ) { + + // lower min equiv ampl if attenuators are in use in -LV units */ + result /= 10.0; + } + + return result; +} diff --git a/device-functions.h b/device-functions.h index ade757a..14100f4 100644 --- a/device-functions.h +++ b/device-functions.h @@ -80,4 +80,6 @@ gboolean fixed_ampl_ok (int channel, float use_ampl); void get_min_max_fixed_ampls (int channel, float *min_ampl, float *max_ampl); gboolean non_zero_first_ampl_point (int channel); +float get_ampl_zero_equiv(int channel); + #endif diff --git a/error_utils.c b/error_utils.c index ccd9837..bf6168d 100644 --- a/error_utils.c +++ b/error_utils.c @@ -845,7 +845,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) break; } - if (fabs(globals.Flash.ampl_zero_equiv[i] > 2000.0)) { + if (fabs(get_ampl_zero_equiv(i) > 2000.0)) { report_error = config_too_large; } @@ -853,7 +853,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) report_error = config_too_large; } - if ( (globals.Flash.ampl_zero_equiv[i] < 0.0) || + if ( (get_ampl_zero_equiv(i) < 0.0) || (globals.Flash.os_zero_equiv[i] < 0.0) || (globals.Flash.hvps_avg_curr_limit[i] < 0.0) || (globals.Flash.max_avg_power[i] < 0.0) ) { @@ -1098,7 +1098,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- check gaps in ampl range, AVRQ -AHV/-XHV ---- */ if (non_zero_first_ampl_point(i)) { - if (fabs(ChannelStateToTest[i].amplitude) < globals.Flash.ampl_zero_equiv[i]) { + if (fabs(ChannelStateToTest[i].amplitude) < get_ampl_zero_equiv(i)) { report_error=amplitude_gap; } } @@ -1212,7 +1212,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* 1011 models: high level of PG-P output must remain positive */ // FIXME use new check_ functions? if (globals.Flash.ampl_coupled_to_os[i]) { - if (ChannelStateToTest[i].amplitude>globals.Flash.ampl_zero_equiv[i]) { + if (ChannelStateToTest[i].amplitude>get_ampl_zero_equiv(i)) { temp=-ChannelStateToTest[i].amplitude; if (temp>globals.Constraints.err_min_offset[i]) { globals.Constraints.err_min_offset[i]=temp; @@ -1247,7 +1247,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* 1011 models: low level of PG-N output must remain negative */ if (globals.Flash.ampl_coupled_to_os[i]) { - if (ChannelStateToTest[i].amplitude<-globals.Flash.ampl_zero_equiv[i]) { + if (ChannelStateToTest[i].amplitude<-get_ampl_zero_equiv(i)) { temp=-ChannelStateToTest[i].amplitude; if (temp<globals.Constraints.err_max_offset[i]) { globals.Constraints.err_max_offset[i]=temp; @@ -2171,7 +2171,6 @@ static int Submenu_Mult_Value(float mult_by) channel=Submenu_Numeric_Parameter%100; if (fabs(Submenu_Value) < smallest_allowed_number) { - printf ("small\n"); if (Submenu_Value < 0.0) { new_value = -smallest_allowed_number * mult_by; } else { @@ -2231,15 +2230,15 @@ static int Submenu_Mult_Value(float mult_by) break; case Show_amplitude: - if (fabs(new_value)<globals.Flash.ampl_zero_equiv[channel] && mult_by>1.0) { - if (new_value<0.0 || globals.Flash.max_ampl[channel]<globals.Flash.ampl_zero_equiv[channel]) { - new_value=-globals.Flash.ampl_zero_equiv[channel]; + if (fabs(new_value)<get_ampl_zero_equiv(channel) && mult_by>1.0) { + if (new_value<0.0 || globals.Flash.max_ampl[channel]<get_ampl_zero_equiv(channel)) { + new_value=-get_ampl_zero_equiv(channel); } else { - new_value=globals.Flash.ampl_zero_equiv[channel]; + new_value=get_ampl_zero_equiv(channel); } } - if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel]) { + if (fabs(new_value) < get_ampl_zero_equiv(channel)) { if (new_value<0.0) { new_value=-smallest_allowed_number; } else { @@ -2501,9 +2500,9 @@ static void Submenu_Service_Encoder(int encoder_change) encoder_change = -encoder_change; } - else if ((channel<max_channels) && abs_Submenu_Value<globals.Flash.ampl_zero_equiv[channel] && (Submenu_Numeric_Parameter-channel)==Show_amplitude) { - abs_Submenu_Value=globals.Flash.ampl_zero_equiv[channel]; - if (globals.Flash.max_ampl[channel]<globals.Flash.ampl_zero_equiv[channel]) { + else if ((channel<max_channels) && abs_Submenu_Value<get_ampl_zero_equiv(channel) && (Submenu_Numeric_Parameter-channel)==Show_amplitude) { + abs_Submenu_Value=get_ampl_zero_equiv(channel); + if (globals.Flash.max_ampl[channel]<get_ampl_zero_equiv(channel)) { Submenu_Value=-abs_Submenu_Value; } } @@ -2695,7 +2694,7 @@ static void Submenu_Service_Encoder(int encoder_change) return; } - if (fabs(new_value) < globals.Flash.ampl_zero_equiv[channel]) { + if (fabs(new_value) < get_ampl_zero_equiv(channel)) { if (Submenu_Value<0.0) { new_value=-smallest_allowed_number; } else { |