diff options
-rwxr-xr-x | libarmep/configuration.c | 6 | ||||
-rw-r--r-- | libarmep/libarmep.h | 2 | ||||
-rw-r--r-- | libarmep/service.c | 32 |
3 files changed, 20 insertions, 20 deletions
diff --git a/libarmep/configuration.c b/libarmep/configuration.c index 2db43a4..7822f4f 100755 --- a/libarmep/configuration.c +++ b/libarmep/configuration.c @@ -56,7 +56,7 @@ static void process_token(struct aep_channel *ch, char *marshall, enum fields fi fprintf(stderr, "**** channel cannot have 0R shunt\n"); break; case AEPC_FIELD_INTERCHANNEL_ERROR_ESTIMATE: - ch->percentage_error_ref = atof(marshall); + ch->channel_num = atoi(marshall); break; case AEPC_FIELD_ZERO_OFFSET_V1: ch->voffset[0] = atof(marshall); @@ -283,10 +283,10 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_ index++; if (ch == wch) { sprintf(linebuf, - " %s\t%f\t%f\t%f\t%f\t%f\t%f\t%d\t%s\t%s\t%s\t%s\n", + " %s\t%f\t%d\t%f\t%f\t%f\t%f\t%d\t%s\t%s\t%s\t%s\n", ch->channel_name, ch->rshunt, - ch->percentage_error_ref, + ch->channel_num, ch->voffset[0], ch->vnoise[0], ch->voffset[1], diff --git a/libarmep/libarmep.h b/libarmep/libarmep.h index c3d8084..f02c292 100644 --- a/libarmep/libarmep.h +++ b/libarmep/libarmep.h @@ -160,8 +160,8 @@ struct aep_channel { char class[16]; /* optional class of power, eg, Soc */ int pretrigger_ms; int pretrigger_samples_taken; + int channel_num; double rshunt; - double percentage_error_ref; double voffset[2]; double vnoise[2]; diff --git a/libarmep/service.c b/libarmep/service.c index 7d569c0..96fdbba 100644 --- a/libarmep/service.c +++ b/libarmep/service.c @@ -107,26 +107,26 @@ static void init_aep(struct aep_context *aep_context, struct aep *aep, const cha static void select_map(struct aep_channel *ch) { - int m; int sel = -1; - double delta = 999999; - for (m = 0; m < (sizeof interp_tables / sizeof interp_tables[0]); m++) { - if (ch->percentage_error_ref <= interp_tables[m].percentage_error_ref) { - if (delta > (interp_tables[m].percentage_error_ref - ch->percentage_error_ref)) { - delta = interp_tables[m].percentage_error_ref - ch->percentage_error_ref; - sel = m; - } - } else { - if (delta > (ch->percentage_error_ref - interp_tables[m].percentage_error_ref)) { - delta = ch->percentage_error_ref - interp_tables[m].percentage_error_ref; - sel = m; - } - } + switch(ch->channel_num) { + case 1: + sel = 0; + break; + case 2: + sel = 1; + break; + case 3: + sel = 2; + break; + default: + fprintf(stderr, "AEP channel number %d is wrong. It's only 3 channel, 1, 2 or 3\n", + ch->channel_num); } + if (ch->aep->aep_context->verbose) - fprintf(stderr, "%s = corr map %d %f%%\n", - ch->channel_name, sel, ch->percentage_error_ref); + fprintf(stderr, "%s = corr map %d %d\n", + ch->channel_name, sel, ch->channel_num); ch->map_table = &interp_tables[sel]; } |