From ba6a0afe0667adcf1ae92c13d4441f34e56c3b96 Mon Sep 17 00:00:00 2001 From: Alexander Ivanov <alexander.ivanov@ligo.org> Date: Thu, 13 Jun 2013 16:13:44 +0000 Subject: [PATCH] Use the GPS time supplied by the front-end when reloading filter coefficients, unless the number is zero, when the front-end code is not started. git-svn-id: https://redoubt.ligo-wa.caltech.edu/svn/advLigoRTS/trunk@3396 6dcd42c9-f523-4c6d-aada-af552506706e --- src/drv/fmReadCoeff.c | 19 ++++++++++++------- src/epics/util/skeleton.st | 6 +++--- src/include/fmReadCoeff.h | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/drv/fmReadCoeff.c b/src/drv/fmReadCoeff.c index 49363818f..9eed5d131 100644 --- a/src/drv/fmReadCoeff.c +++ b/src/drv/fmReadCoeff.c @@ -120,7 +120,7 @@ void memcpy_swap_words(void *dest, void *src) { #endif /// Read system 'fmc' coeffs for subsys 'n' -int fmReadCoeffFile(fmReadCoeff *fmc, int n) { +int fmReadCoeffFile(fmReadCoeff *fmc, int n, unsigned long gps) { int i, j, k; int ix; @@ -204,13 +204,18 @@ int fmReadCoeffFile(fmReadCoeff *fmc, int n) { char buf[128]; unsigned long t = 0; - // See if we have /proc/gps time and read the GPS time from it - FILE *f = fopen("/proc/gps", "r"); - if (f) { - if (fgets(buf, 128, f)) { - t = atol(buf); + // If GPS time is supplied by the front-end, use that + if (gps > 0) { + t = gps; + } else { + // See if we have /proc/gps time and read the GPS time from it + FILE *f = fopen("/proc/gps", "r"); + if (f) { + if (fgets(buf, 128, f)) { + t = atol(buf); + } + close(f); } - close(f); } // Failed to get the time from /proc/gps, so use system time diff --git a/src/epics/util/skeleton.st b/src/epics/util/skeleton.st index 1a7c169a3..3efa0bf9b 100644 --- a/src/epics/util/skeleton.st +++ b/src/epics/util/skeleton.st @@ -389,7 +389,7 @@ state init strcpy(msg, "Reading coeff file..."); pvPut(msg); -%% if (fmReadCoeffFile(&fmc, 0) != 0) { +%% if (fmReadCoeffFile(&fmc, 0, pEpics->epicsOutput.timeDiag) != 0) { %% fprintf(stderr, "Error: %s\n", fmReadErrMsg()); strncpy(msg, fmReadShortErrMsg(), MAX_STRING_SIZE-1); %% } else { @@ -538,7 +538,7 @@ state monScreen{ pvPut(msg); %% /* printf("About to read file \n"); */ -%% if (fmReadCoeffFile(&fmc, 0) != 0) { +%% if (fmReadCoeffFile(&fmc, 0, pEpics->epicsOutput.timeDiag) != 0) { %% fprintf(stderr, "Error: %s\n", fmReadErrMsg()); strncpy(msg, fmReadShortErrMsg(), MAX_STRING_SIZE-1); pvPut(msg); @@ -979,7 +979,7 @@ state filtCoefChk %% /* printf("About to read file \n"); */ -%% if (fmReadCoeffFile(&fmc, 0) != 0) { +%% if (fmReadCoeffFile(&fmc, 0, pEpics->epicsOutput.timeDiag) != 0) { %% fprintf(stderr, "Error: %s\n", fmReadErrMsg()); strncpy(msg, fmReadShortErrMsg(), MAX_STRING_SIZE-1); pvPut(msg); diff --git a/src/include/fmReadCoeff.h b/src/include/fmReadCoeff.h index f106052e9..6f84c773f 100644 --- a/src/include/fmReadCoeff.h +++ b/src/include/fmReadCoeff.h @@ -49,7 +49,7 @@ typedef struct fmReadCoeff { #define TF_THRESHOLDS_NOT_FOUND 2 /* MA */ #define TF_PARSE_ERROR 3 /* MA */ -int fmReadCoeffFile(fmReadCoeff *, int); +int fmReadCoeffFile(fmReadCoeff *, int, unsigned long); char* fmReadErrMsg(); char* fmReadShortErrMsg(); -- GitLab