summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:02:02 +0900
committerroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:02:02 +0900
commitb9aed70d02c6daa5bac9a9aa5f67c6c8c94358e0 (patch)
tree2fd1bc6e02877057f8341e85c1a10a480b94fe75
parenta95b1e0197bcd35c6a45a4c18f5a5fbe7cd4365c (diff)
account for min/max fixed amplitudes in error checker
-rw-r--r--device-functions.c17
-rw-r--r--device-functions.h1
-rw-r--r--error_utils.c40
3 files changed, 47 insertions, 11 deletions
diff --git a/device-functions.c b/device-functions.c
index 1d27a3a..e1ec380 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -4992,3 +4992,20 @@ gboolean fixed_ampl_ok (int channel, float use_ampl) {
}
return FALSE;
}
+
+
+void get_min_max_fixed_ampls (int channel, float *min_ampl, float *max_ampl) {
+ int i,max;
+ max = number_of_fixed_ampl_points(channel);
+
+ *min_ampl = 1e9;
+ *max_ampl = -1e9;
+
+ for (i=0; i<max; i++) {
+ float use_ampl;
+ use_ampl = globals.Flash.fixed_ampl_points[channel][i];
+
+ if (use_ampl > *max_ampl) *max_ampl = use_ampl;
+ if (use_ampl < *min_ampl) *min_ampl = use_ampl;
+ }
+}
diff --git a/device-functions.h b/device-functions.h
index 9c33b81..cdbbd9c 100644
--- a/device-functions.h
+++ b/device-functions.h
@@ -78,5 +78,6 @@ int change_password (gchar *old_password, gchar *new_password);
int number_of_fixed_ampl_points(int channel);
float rst_fixed_ampl_point (int channel);
gboolean fixed_ampl_ok (int channel, float use_ampl);
+void get_min_max_fixed_ampls (int channel, float *min_ampl, float *max_ampl);
#endif
diff --git a/error_utils.c b/error_utils.c
index d339bdf..bd52ccc 100644
--- a/error_utils.c
+++ b/error_utils.c
@@ -1095,8 +1095,30 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
+ /* --- check fixed amplitudes ---- */
+
+ float min_fixed_ampl, max_fixed_ampl;
+ min_fixed_ampl = max_fixed_ampl = 0.0;
+
+ gboolean uses_fixed_ampl;
+ uses_fixed_ampl = (number_of_fixed_ampl_points(i)>0);
+
+ if (uses_fixed_ampl) {
+ get_min_max_fixed_ampls (i, &min_fixed_ampl, &max_fixed_ampl);
+
+ if (!fixed_ampl_ok (i, ChannelStateToTest[i].amplitude)) {
+ report_error=amplitude_confined_values;
+ }
+ }
+ /* ------------------------------- */
+
/* --- check minimum amplitude --- */
- globals.Constraints.err_min_ampl[i]=globals.Flash.min_ampl[i];
+
+ if (uses_fixed_ampl && (min_fixed_ampl > globals.Flash.min_ampl[i])) {
+ globals.Constraints.err_min_ampl[i]=min_fixed_ampl;
+ } else {
+ 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])) ) {
@@ -1115,18 +1137,14 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
/* ------------------------------- */
- /* --- check intermediate amplitude --- */
- if (number_of_fixed_ampl_points(i)>0) {
- if (!fixed_ampl_ok (i, ChannelStateToTest[i].amplitude)) {
- report_error=amplitude_confined_values;
- }
- }
- /* ------------------------------- */
-
-
/* --- check maximum amplitude --- */
- globals.Constraints.err_max_ampl[i]=globals.Flash.max_ampl[i];
+ if (uses_fixed_ampl && (max_fixed_ampl < globals.Flash.max_ampl[i])) {
+ globals.Constraints.err_max_ampl[i]=max_fixed_ampl;
+ } else {
+ 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])) ) {
report_error=amplitude_upper_limit;