hi!
This commit is contained in:
33
tecsdriv.c
33
tecsdriv.c
@@ -69,24 +69,22 @@
|
||||
typedef struct {
|
||||
void *pData;
|
||||
char *lastError;
|
||||
time_t lastGet;
|
||||
int iLastError, port;
|
||||
char server[256];
|
||||
} TecsDriv, *pTecsDriv;
|
||||
|
||||
|
||||
static time_t lastGet=0;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
int TecsWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
char pBueffel[256];
|
||||
char pBueffel[256], result[256];
|
||||
int iRet;
|
||||
pEVDriver pD;
|
||||
pTecsDriv pMe;
|
||||
char *result;
|
||||
double fNum;
|
||||
float fVal;
|
||||
|
||||
@@ -111,7 +109,7 @@
|
||||
pD=self->pDriv; assert(pD);
|
||||
pMe=pD->pPrivate; assert(pMe);
|
||||
if(argc > 2) { /* set case */
|
||||
iRet=TeccSetPar(pMe->pData,argv[1],argv[2]);
|
||||
iRet=CocSet(pMe->pData,argv[1],argv[2]);
|
||||
if (iRet<0) {
|
||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
@@ -119,8 +117,8 @@
|
||||
}
|
||||
return 1;
|
||||
} else { /* get case */
|
||||
result=TeccGetPar(pMe->pData,argv[1]);
|
||||
if (result==NULL) {
|
||||
iRet=CocGet(pMe->pData,argv[1],result);
|
||||
if (iRet<0) {
|
||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
@@ -138,40 +136,45 @@
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
static int TecsGet(pEVDriver self, float *fPos)
|
||||
{
|
||||
pTecsDriv pMe = NULL;
|
||||
int iRet;
|
||||
time_t now;
|
||||
static int configuring;
|
||||
|
||||
assert(self);
|
||||
pMe = (pTecsDriv)self->pPrivate;
|
||||
assert(pMe);
|
||||
|
||||
time(&now);
|
||||
if (now!=lastGet) { /* TecsGet was not yet called within this second */
|
||||
lastGet=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) */
|
||||
}
|
||||
|
||||
/* get temperature */
|
||||
iRet = TeccGet(pMe->pData, fPos);
|
||||
if (iRet > 1) {
|
||||
if (pMe->iLastError==2) {
|
||||
iRet=TeccWait(pMe->pData);
|
||||
if (iRet > 0) {
|
||||
if (configuring) {
|
||||
iRet = TeccWait(pMe->pData);
|
||||
iRet = TeccGet(pMe->pData, fPos);
|
||||
} else {
|
||||
pMe->lastError = "configuring controller";
|
||||
pMe->lastError = ": controller busy (configuring)";
|
||||
pMe->iLastError=2; /* fixable */
|
||||
configuring=1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
configuring=0;
|
||||
if(iRet < 0) {
|
||||
pMe->lastError = ErrMessage;
|
||||
pMe->iLastError=1; /* severe */
|
||||
return 0;
|
||||
}
|
||||
pMe->lastError=0;
|
||||
pMe->iLastError=0;
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -219,7 +222,7 @@
|
||||
assert(self);
|
||||
pMe = (pTecsDriv )self->pPrivate;
|
||||
assert(pMe);
|
||||
if (pMe->iLastError=1) { /* for Tecs, iLastError means severity level */
|
||||
if (pMe->iLastError==1) { /* for Tecs, iLastError means severity level */
|
||||
return(DEVFAULT); /* 1: severe */
|
||||
} else {
|
||||
return(DEVREDO); /* 2: try again, good luck! */
|
||||
|
||||
Reference in New Issue
Block a user