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