diffscan skip to mSec, initialize each new scan

This commit is contained in:
Douglas Clowes
2012-11-28 16:24:56 +11:00
parent b22906ba2d
commit 70744522be
2 changed files with 21 additions and 0 deletions

View File

@ -15,6 +15,8 @@
#include "drive.h" #include "drive.h"
#include "counter.h" #include "counter.h"
extern double DoubleTime(void);
#define DIFFMONITOR 0 #define DIFFMONITOR 0
#define SKIP 1 #define SKIP 1
@ -180,6 +182,7 @@ static int StartDiffScan(pDiffScan self, pScanData pScan,
self->scaleMonitor = (int) ObVal(self->parArray, DIFFMONITOR); self->scaleMonitor = (int) ObVal(self->parArray, DIFFMONITOR);
self->normalizationScale = -1; self->normalizationScale = -1;
pScan->iCounts = 0; pScan->iCounts = 0;
pScan->iNP = 0;
/* /*
get variable get variable
@ -190,6 +193,7 @@ static int StartDiffScan(pDiffScan self, pScanData pScan,
SCWrite(pCon, "ERROR: cannot access scan variable", eError); SCWrite(pCon, "ERROR: cannot access scan variable", eError);
return 0; return 0;
} }
InitScanVar(pVar);
/* /*
drive to start position drive to start position
@ -271,12 +275,26 @@ static int DiffScanTask(void *pData)
char pBueffel[255]; char pBueffel[255];
long rawCount, rawMon; long rawCount, rawMon;
CountEntry rawCopy; CountEntry rawCopy;
double now;
pDiffScan self = (pDiffScan) pData; pDiffScan self = (pDiffScan) pData;
/* /*
manage skip 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->skip > 0) {
if (self->skipCount > self->skip) { if (self->skipCount > self->skip) {
self->skipCount = 0; self->skipCount = 0;
@ -285,6 +303,7 @@ static int DiffScanTask(void *pData)
return 1; return 1;
} }
} }
#endif
/* /*
read motor status read motor status
@ -385,6 +404,7 @@ int RunDiffScan(pDiffScan self, pScanData pScan,
if (StartDiffScan(self, pScan, pCon, fEnd) != 1) { if (StartDiffScan(self, pScan, pCon, fEnd) != 1) {
return 0; return 0;
} }
self->last_report_time = DoubleTime();
InvokeCallBack(self->scanObject->pCall, SCANSTART, self->scanObject); InvokeCallBack(self->scanObject->pCall, SCANSTART, self->scanObject);

View File

@ -22,6 +22,7 @@ typedef struct {
int skip; int skip;
int skipCount; int skipCount;
pScanData scanObject; pScanData scanObject;
double last_report_time;
} DiffScan, *pDiffScan; } DiffScan, *pDiffScan;
/*==================================================================*/ /*==================================================================*/