improved tecs driver M.Z.

This commit is contained in:
cvs
2004-03-09 15:18:01 +00:00
parent 7422a261ea
commit 55848218a4
23 changed files with 1372 additions and 713 deletions

View File

@@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------
T E C S D R I V . C
This is the implementation for TECS object derived from an more general
environment controller. At present, TECS is used for driving the
LakeShore 340 Temperutre Controller.
LakeShore 340 Temperature Controller.
Markus Zolliker, March 2000
@@ -68,6 +68,7 @@
char *lastError;
time_t lastGet;
int iLastError, port;
int (*EVLimits)(void *, float , char *, int);
char server[256];
} TecsDriv, *pTecsDriv;
@@ -78,7 +79,7 @@
int argc, char *argv[])
{
pEVControl self = NULL;
char pBueffel[256], result[1024];
char pBueffel[256], result[1024], *res;
int iRet;
pEVDriver pD;
pTecsDriv pMe;
@@ -111,43 +112,51 @@
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
if (iRet<0) goto Error;
self->fTarget = atof(result);
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */
if (iRet<0) goto Error;
fVal = atof(result);
iRet = EVCSetPar(self, "upperlimit", fVal,pCon);
iRet = EVControlWrapper(pCon,pSics,pData,argc,argv);
if (iRet != 0) {
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */
if (iRet<0) goto Error;
fVal = atof(result);
if (fVal != 0 && ObVal(self->pParam,UPLIMIT) > fVal) {
sprintf(pBueffel,"WARNING: upper limit is above %g, (limit of the device)", fVal);
SCWrite(pCon,pBueffel,eValue);
}
iRet=CocGet(pMe->pData,"status",result); /* get parameter */
iRet=CocGet(pMe->pData,"status",result); /* show status */
if (iRet<0) goto Error;
SCWrite(pCon,result,eValue);
}
return iRet;
} else if (0==strcmp(pBueffel," upperlimit ")) {
if (argc > 2) {
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */
if (iRet<0) goto Error;
fVal=atof(result);
if (atof(argv[2]) > fVal) {
sprintf(pBueffel,"ERROR: upper limit must not be higher than %g", fVal);
SCWrite(pCon,pBueffel,eError);
return 0;
}
if (argc == 3) {
iRet=CocSetGet(pMe->pData,"tLimit",argv[2],result); /* set and get parameter */
res=strchr(result, '=');
if (res != NULL) {
str_copy(result, res+1);
}
} else if (argc == 2) {
iRet=CocGet(pMe->pData,"tLimit",result); /* get parameter */
}
return EVControlWrapper(pCon,pSics,pData,argc,argv);
if (iRet<0) goto Error;
fVal=atof(result);
if (argc==3 && atof(argv[2]) > fVal) {
sprintf(pBueffel,"WARNING: upper limit reduced to maximal allowed value: %g", fVal);
SCWrite(pCon,pBueffel,eWarning);
}
iRet = EVCSetPar(self, "upperlimit", fVal,pCon);
if (iRet) {
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
argv[1],result);
SCWrite(pCon,pBueffel,eValue);
}
return iRet;
} else if (0==strcmp(pBueffel," lowerlimit ")) {
if (argc > 2) {
if (atof(argv[2]) > ObVal(self->pParam,UPLIMIT)) {
SCWrite(pCon,"ERROR: lower limit must not be higher than upperlimit",eError);
return 0;
}
}
}
return EVControlWrapper(pCon,pSics,pData,argc,argv);
} else if (NULL!=strstr(
" log send tolerance access errorhandler interrupt interest safevalue currentvalue maxwait settle "
, pBueffel)) {
" log send tolerance access errorhandler interrupt interest safevalue currentvalue maxwait settle errorscript driver "
, pBueffel)) {
/* forward to standard handler */
return EVControlWrapper(pCon,pSics,pData,argc,argv);
}
@@ -386,12 +395,12 @@
pPort=fgets(buf, sizeof(buf), fil);
if (pPort != NULL) {
pMe->port=atoi(pPort);
}
fgets(buf, sizeof(buf), fil);
fgets(pMe->server, sizeof(pMe->server), fil);
}
fgets(buf, sizeof(buf), fil);
fgets(pMe->server, sizeof(pMe->server), fil);
}
}
if (pMe->port==0) {
/* get the port number for tecs */
pPort = IFindOption(pSICSOptions, "TecsPort");
@@ -414,4 +423,38 @@
pNew->GetValues= TecsGetX;
return pNew;
}
}
/*------------------------------------------------------------------------*/
static int TecsLimits(void *pData, float fVal, char *pError, int iErrLen) {
/* wrapper for EVILimits */
pEVControl pEvc;
pTecsDriv pMe;
int iRet;
float f;
char result[64];
pEvc = (pEVControl)pData;
assert(pEvc);
pMe=pEvc->pDriv->pPrivate;
assert(pMe);
iRet=CocGet(pMe->pData,"tLimit",result); /* get parameter */
if (iRet>=0) {
f=0.0;
f=atof(result);
if (f>0.0) pEvc->pParam[UPLIMIT].fVal=f;
}
return pMe->EVLimits(pData, fVal, pError, iErrLen);
}
/*------------------------------------------------------------------------*/
void TecsCustomize(SConnection *pCon, pEVControl pEvc) {
/* customize tecs driver */
pTecsDriv pMe;
pMe=pEvc->pDriv->pPrivate;
assert(pMe);
assert(pMe->EVLimits != pEvc->pDrivInt->CheckLimits);
pMe->EVLimits=pEvc->pDrivInt->CheckLimits; /* save original CheckLimits function */
pEvc->pDrivInt->CheckLimits=TecsLimits;
EVCSetPar(pEvc,"upperlimit",1800.0,pCon);
EVCSetPar(pEvc,"lowerlimit",0.01,pCon);
}