Convert difscan skip count to be milliseconds

r3639 | dcl | 2012-07-11 15:12:51 +1000 (Wed, 11 Jul 2012) | 1 line
This commit is contained in:
Douglas Clowes
2012-07-11 15:12:51 +10:00
parent f5537d7c9e
commit 25c10fb105
2 changed files with 20 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
@@ -259,12 +261,27 @@ 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;
@@ -273,6 +290,7 @@ static int DiffScanTask(void *pData){
return 1; return 1;
} }
} }
#endif
/* /*
read motor status read motor status
@@ -353,6 +371,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;
/*==================================================================*/ /*==================================================================*/