bug fixes and enhancements related to evcontroller
SKIPPED: psi/dilludriv.c psi/el755driv.c psi/eurodriv.c psi/eve.c psi/eve.h psi/fsm.c psi/ipsdriv.c psi/itc4driv.c psi/itcdriv.c psi/lcdriv.c psi/logger.c psi/logger.h psi/slsmagnet.c
This commit is contained in:
@ -679,7 +679,6 @@ static void ErrReport(pEVControl self)
|
||||
return NULL;
|
||||
}
|
||||
pRes->pDes->GetInterface = EVIInterface;
|
||||
pRes->pDes->SaveStatus = EVSaveStatus;
|
||||
|
||||
/* new Drivable interface */
|
||||
pRes->pDrivInt = CreateDrivableInterface();
|
||||
@ -780,6 +779,7 @@ static void ErrReport(pEVControl self)
|
||||
if(self->pDes)
|
||||
{
|
||||
DeleteDescriptor(self->pDes);
|
||||
self->pDes = NULL;
|
||||
}
|
||||
if(self->pDrivInt)
|
||||
{
|
||||
@ -1196,6 +1196,7 @@ static void ErrReport(pEVControl self)
|
||||
}
|
||||
self->errorScript = strdup(pBueffel);
|
||||
SCSendOK(pCon);
|
||||
SCparChange(pCon);
|
||||
return 1;
|
||||
}
|
||||
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
|
||||
@ -1209,20 +1210,46 @@ static void ErrReport(pEVControl self)
|
||||
if(iRet)
|
||||
{
|
||||
SCSendOK(pCon);
|
||||
SCparChange(pCon);
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
return 0; /* not reached */
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int EVSaveStatus(void *pData, char *name, FILE *fil)
|
||||
static int EVSaveStatus(void *pData, char *name, FILE *fil)
|
||||
{
|
||||
pEVControl evc = pData;
|
||||
if (evc->creationArgs) {
|
||||
fprintf(fil, "evfactory replace %s %s\n", name, evc->creationArgs);
|
||||
pEVDriver pD = evc->pDriv;
|
||||
|
||||
assert(evc);
|
||||
assert(pD);
|
||||
if (evc->creationArgs && pD->SavePars) {
|
||||
fprintf(fil, "if {[catch { evfactory replace %s %s }] == 0} {\n", name, evc->creationArgs);
|
||||
if (pD->SavePars(pD, fil) == 1) {
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "tolerance", ObVal(evc->pParam,TOLERANCE));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "access", ObVal(evc->pParam,ACCESS));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "ErrorHandler", ObVal(evc->pParam,ERRORHANDLER));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "interrupt", ObVal(evc->pParam,INTERRUPT));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "UpperLimit", ObVal(evc->pParam,UPLIMIT));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "LowerLimit", ObVal(evc->pParam,LOWLIMIT));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "SafeValue", ObVal(evc->pParam,SAFEVALUE));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "MaxWait", ObVal(evc->pParam,MAXWAIT));
|
||||
fprintf(fil, " %s %s %g\n",evc->pName, "Settle", ObVal(evc->pParam,SETTLE));
|
||||
if(evc->errorScript != NULL) {
|
||||
fprintf(fil, " %s errorScript %s\n", evc->pName, evc->errorScript);
|
||||
}
|
||||
}
|
||||
fprintf(fil, "}\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* standard method for saving parameters */
|
||||
static int EVCSaveStd(void *pData, char *name, FILE *fil)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
pEVControl MakeEVController(pEVDriver pDriv, SConnection *pCon,
|
||||
ObjectFunc wrapper, int argc, char *argv[])
|
||||
@ -1238,12 +1265,15 @@ pEVControl MakeEVController(pEVDriver pDriv, SConnection *pCon,
|
||||
}
|
||||
pNew = CreateEVController(pDriv,argv[0],&status);
|
||||
if (status != 1) {
|
||||
printf("CEVC error\n");
|
||||
SCWrite(pCon,"ERROR: failed to initialize device", eError);
|
||||
pDriv->GetError(pDriv,&status,pError,sizeof pError -1);
|
||||
printf("HW %s\n", pError);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
if (pNew == NULL) {
|
||||
printf("CEVC failed\n");
|
||||
SCWrite(pCon,"ERROR: failed to create environment device object",
|
||||
eError);
|
||||
DeleteEVDriver(pDriv);
|
||||
@ -1368,6 +1398,29 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
||||
}
|
||||
return pNew;
|
||||
}
|
||||
|
||||
int RemoveEVController(SConnection *pCon, char *name) {
|
||||
char pBueffel[512];
|
||||
int iRet;
|
||||
|
||||
if(!pServ->pExecutor)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(isInRunMode(pServ->pExecutor))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: cannot delete while running",eError);
|
||||
return 0;
|
||||
}
|
||||
EVUnregister(FindEMON(pServ->pSics),name);
|
||||
iRet = RemoveCommand(pServ->pSics,name);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s not found, NOT deleted",name);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
EVControlFactory implements a SICS command which creates and deletes
|
||||
Controllers at run-time. Syntax:
|
||||
@ -1405,26 +1458,12 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"del") == 0) /* delete */
|
||||
{
|
||||
if(!pServ->pExecutor)
|
||||
{
|
||||
if (RemoveEVController(pCon, argv[2])) {
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
if(isInRunMode(pServ->pExecutor))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: cannot delete while running",eError);
|
||||
return 0;
|
||||
}
|
||||
EVUnregister(FindEMON(pSics),argv[2]);
|
||||
iRet = RemoveCommand(pSics,argv[2]);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s not found, NOT deleted",argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[1],"new") == 0 || strcmp(argv[1], "replace") == 0)
|
||||
/* make a new one */
|
||||
@ -1441,8 +1480,9 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
||||
strtolower(argv[3]);
|
||||
if (FindCommandData(pSics, argv[2], "Environment Controller")) {
|
||||
if (strcmp(argv[1], "replace") == 0) {
|
||||
RemoveCommand(pSics, argv[2]);
|
||||
EVUnregister(FindEMON(pSics),argv[2]);
|
||||
if (!RemoveEVController(pCon, argv[2])) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
sprintf(pBueffel,
|
||||
"ERROR: environment device %s already installed, delete first",
|
||||
@ -1474,9 +1514,14 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
||||
if(pNew == NULL){
|
||||
/* error message is already written */
|
||||
return 0;
|
||||
}
|
||||
Arg2Text(argc-3, argv+3, pBueffel, sizeof pBueffel);
|
||||
pNew->creationArgs = strdup(pBueffel);
|
||||
}
|
||||
if (pNew->pDriv->SavePars) {
|
||||
Arg2Text(argc-3, argv+3, pBueffel, sizeof pBueffel);
|
||||
pNew->creationArgs = strdup(pBueffel);
|
||||
pNew->pDes->SaveStatus = EVSaveStatus;
|
||||
} else {
|
||||
pNew->creationArgs = NULL;
|
||||
}
|
||||
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
pNew->driverName = strdup(argv[3]);
|
||||
|
Reference in New Issue
Block a user