- removed a 0.2 sec delay when communicating with the TecsServer
This commit is contained in:
42
tecsdriv.c
42
tecsdriv.c
@ -61,12 +61,14 @@
|
||||
#include "tecs/myc_str.h"
|
||||
#include "tecs/myc_err.h"
|
||||
#include <evdriver.i>
|
||||
#include "statistics.h"
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
void *pData;
|
||||
char *lastError;
|
||||
time_t lastGet;
|
||||
time_t lastGet, lastGetX;
|
||||
float lastValue, lastPos, lastDelta;
|
||||
int iLastError, port;
|
||||
int (*EVLimits)(void *, float , char *, int);
|
||||
char server[256];
|
||||
@ -225,7 +227,9 @@ void outFunc(char *str, void *arg) {
|
||||
pTecsDriv pMe = NULL;
|
||||
int iRet;
|
||||
time_t now;
|
||||
|
||||
static Statistics *stat = NULL;
|
||||
Statistics *old;
|
||||
|
||||
assert(self);
|
||||
pMe = (pTecsDriv)self->pPrivate;
|
||||
assert(pMe);
|
||||
@ -233,12 +237,20 @@ void outFunc(char *str, void *arg) {
|
||||
time(&now);
|
||||
if (now!=pMe->lastGet) { /* TecsGet was not yet called within this second */
|
||||
pMe->lastGet=now;
|
||||
} else {
|
||||
CocDelay(200); /* wait 0.2 sec. (seems that SICS has nothing else to do then reading temperatures) */
|
||||
} else { /* do not call tecs again, as we have already quite recent values */
|
||||
*fPos = pMe->lastValue;
|
||||
pMe->iLastError=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stat == NULL) stat = StatisticsNew("TecsGet");
|
||||
old = StatisticsBegin(stat);
|
||||
|
||||
/* get temperature */
|
||||
iRet = TeccGet(pMe->pData, fPos);
|
||||
StatisticsEnd(old);
|
||||
|
||||
pMe->lastValue = *fPos;
|
||||
if(iRet < 0) {
|
||||
pMe->lastError = ErrMessage;
|
||||
pMe->iLastError=1; /* severe */
|
||||
@ -254,20 +266,32 @@ void outFunc(char *str, void *arg) {
|
||||
pTecsDriv pMe = NULL;
|
||||
int iRet;
|
||||
time_t now;
|
||||
static Statistics *stat = NULL;
|
||||
Statistics *old;
|
||||
|
||||
assert(self);
|
||||
pMe = (pTecsDriv)self->pPrivate;
|
||||
assert(pMe);
|
||||
|
||||
time(&now);
|
||||
if (now!=pMe->lastGet) { /* TecsGet was not yet called within this second */
|
||||
pMe->lastGet=now;
|
||||
} else {
|
||||
CocDelay(200); /* wait 0.2 sec. (seems that SICS has nothing else to do then reading temperatures) */
|
||||
if (now!=pMe->lastGetX) { /* TecsGetX was not yet called within this second */
|
||||
pMe->lastGetX=now;
|
||||
} else { /* do not call tecs again, as we have already quite recent values */
|
||||
*fPos = pMe->lastPos;
|
||||
*fDelta = pMe->lastDelta;
|
||||
pMe->iLastError=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* get temperature */
|
||||
if (stat == NULL) stat = StatisticsNew("TecsGetX");
|
||||
old = StatisticsBegin(stat);
|
||||
|
||||
/* get temperatures */
|
||||
iRet = TeccGetX(pMe->pData, fTarget, fPos, fDelta);
|
||||
StatisticsEnd(old);
|
||||
|
||||
pMe->lastPos = *fPos;
|
||||
pMe->lastDelta = *fDelta;
|
||||
if(iRet < 0) {
|
||||
pMe->lastError = ErrMessage;
|
||||
pMe->iLastError=1; /* severe */
|
||||
|
Reference in New Issue
Block a user