From 70744522bebf9ab6a716bd372c05b0c0a5fb0048 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 28 Nov 2012 16:24:56 +1100 Subject: [PATCH] diffscan skip to mSec, initialize each new scan --- diffscan.c | 20 ++++++++++++++++++++ diffscan.h | 1 + 2 files changed, 21 insertions(+) diff --git a/diffscan.c b/diffscan.c index 0dd9e54d..315bcb19 100644 --- a/diffscan.c +++ b/diffscan.c @@ -15,6 +15,8 @@ #include "drive.h" #include "counter.h" +extern double DoubleTime(void); + #define DIFFMONITOR 0 #define SKIP 1 @@ -180,6 +182,7 @@ static int StartDiffScan(pDiffScan self, pScanData pScan, self->scaleMonitor = (int) ObVal(self->parArray, DIFFMONITOR); self->normalizationScale = -1; pScan->iCounts = 0; + pScan->iNP = 0; /* get variable @@ -190,6 +193,7 @@ static int StartDiffScan(pDiffScan self, pScanData pScan, SCWrite(pCon, "ERROR: cannot access scan variable", eError); return 0; } + InitScanVar(pVar); /* drive to start position @@ -271,12 +275,26 @@ static int DiffScanTask(void *pData) char pBueffel[255]; long rawCount, rawMon; CountEntry rawCopy; + double now; pDiffScan self = (pDiffScan) pData; /* manage skip */ +#if 1 + now = DoubleTime(); + if (self->skip > 0) { + if (now - self->last_report_time < 0.001 * self->skip) { + return 1; + } + } else { + if (now - self->last_report_time < 0.1) { + return 1; + } + } + self->last_report_time = now; +#else if (self->skip > 0) { if (self->skipCount > self->skip) { self->skipCount = 0; @@ -285,6 +303,7 @@ static int DiffScanTask(void *pData) return 1; } } +#endif /* read motor status @@ -385,6 +404,7 @@ int RunDiffScan(pDiffScan self, pScanData pScan, if (StartDiffScan(self, pScan, pCon, fEnd) != 1) { return 0; } + self->last_report_time = DoubleTime(); InvokeCallBack(self->scanObject->pCall, SCANSTART, self->scanObject); diff --git a/diffscan.h b/diffscan.h index 75adce42..652344f1 100644 --- a/diffscan.h +++ b/diffscan.h @@ -22,6 +22,7 @@ typedef struct { int skip; int skipCount; pScanData scanObject; + double last_report_time; } DiffScan, *pDiffScan; /*==================================================================*/