New TECS Version Sept. 2001 M.Z.
This commit is contained in:
142
tecsdriv.c
142
tecsdriv.c
@@ -38,6 +38,7 @@
|
||||
MODIFICATIONS.
|
||||
----------------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
@@ -57,8 +58,8 @@
|
||||
#include "sicsvar.h"
|
||||
#include "tecs/coc_util.h"
|
||||
#include "tecs/tecs_cli.h"
|
||||
#include "tecs/str_util.h"
|
||||
#include "tecs/err_handling.h"
|
||||
#include "tecs/myc_str.h"
|
||||
#include "tecs/myc_err.h"
|
||||
extern pServer pServ;
|
||||
|
||||
#include "evdriver.i"
|
||||
@@ -83,7 +84,6 @@
|
||||
int iRet;
|
||||
pEVDriver pD;
|
||||
pTecsDriv pMe;
|
||||
double fNum;
|
||||
float fVal;
|
||||
|
||||
self = (pEVControl)pData;
|
||||
@@ -96,46 +96,85 @@
|
||||
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||
}
|
||||
|
||||
pD=self->pDriv; assert(pD);
|
||||
pMe=pD->pPrivate; assert(pMe);
|
||||
strcpy(pBueffel, " ");
|
||||
strcat(pBueffel, argv[1]);
|
||||
strcat(pBueffel, " ");
|
||||
strtolower(pBueffel);
|
||||
if ( NULL==strstr(" log send list tolerance access errorhandler interrupt interest ", pBueffel)
|
||||
&& NULL==strstr(" upperlimit lowerlimit safevalue currentvalue targetvalue ", pBueffel)
|
||||
) {
|
||||
|
||||
pD=self->pDriv; assert(pD);
|
||||
pMe=pD->pPrivate; assert(pMe);
|
||||
if(argc > 2) { /* set case */
|
||||
iRet=CocSet(pMe->pData,argv[1],argv[2]);
|
||||
if (iRet<0) {
|
||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
} else { /* get case (or command without parameter) */
|
||||
if (0==strcasecmp(argv[1], "kill")) {
|
||||
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
||||
strcpy(result, "1");
|
||||
} else {
|
||||
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
||||
}
|
||||
if (iRet<0) {
|
||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
|
||||
argv[1],result);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
if (0==strcmp(pBueffel," targetvalue ")) {
|
||||
if (argc == 2) {
|
||||
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
|
||||
if (iRet<0) goto Error;
|
||||
self->fTarget = atof(result);
|
||||
}
|
||||
} else {
|
||||
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||
} else if (0==strcmp(pBueffel," list ")) {
|
||||
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
|
||||
if (iRet<0) goto Error;
|
||||
self->fTarget = atof(result);
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
}
|
||||
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||
} 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 "
|
||||
, pBueffel)) {
|
||||
/* forward to standard handler */
|
||||
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||
}
|
||||
if(argc > 2) { /* set case */
|
||||
iRet=CocSet(pMe->pData,argv[1],argv[2]);
|
||||
if (iRet<0) goto Error;
|
||||
return 1;
|
||||
} else { /* get case (or command without parameter) */
|
||||
if (0==strcasecmp(argv[1], "kill")) {
|
||||
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
||||
strcpy(result, "1");
|
||||
} else {
|
||||
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
||||
}
|
||||
if (iRet<0) goto Error;
|
||||
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
|
||||
argv[1],result);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
/* not reached */
|
||||
return 0;
|
||||
Error:
|
||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -292,8 +331,10 @@
|
||||
pEVDriver pNew = NULL;
|
||||
pTecsDriv pMe = NULL;
|
||||
pSicsVariable pInst = NULL;
|
||||
char *pPort=NULL;
|
||||
|
||||
char *pPort=NULL, *pPath=NULL;
|
||||
FILE *fil;
|
||||
char buf[256];
|
||||
|
||||
pNew = CreateEVDriver(argc,argv);
|
||||
pMe = (pTecsDriv)malloc(sizeof(TecsDriv));
|
||||
memset(pMe,0,sizeof(TecsDriv));
|
||||
@@ -307,16 +348,31 @@
|
||||
/* initalise pTecsDriver */
|
||||
pMe->lastError = NULL;
|
||||
|
||||
pMe->port=0;
|
||||
pMe->server[0]='\0';
|
||||
|
||||
/* get the port number for tecs */
|
||||
pMe->port=0;
|
||||
pPort = IFindOption(pSICSOptions, "TecsPort");
|
||||
if (pPort!=NULL) {
|
||||
pMe->port=atoi(pPort);
|
||||
pPath = IFindOption(pSICSOptions, "TecsInit");
|
||||
if (pPath != NULL) {
|
||||
fil=fopen(pPath, "r");
|
||||
if (fil!=NULL) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (pMe->port==0) {
|
||||
pMe->port=9753;
|
||||
/* get the port number for tecs */
|
||||
pPort = IFindOption(pSICSOptions, "TecsPort");
|
||||
if (pPort!=NULL) {
|
||||
pMe->port=atoi(pPort);
|
||||
}
|
||||
if (pMe->port==0) {
|
||||
pMe->port=9753;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialise function pointers */
|
||||
|
||||
Reference in New Issue
Block a user