- extended evcontroller

- remote objects
- new ev drivers for oxford IPS,ITC,ILM and LC
M.Z.


SKIPPED:
	psi/eve.c
	psi/eve.h
	psi/fsm.c
	psi/fsm.h
	psi/ilmdriv.c
	psi/ipsdriv.c
	psi/itcdriv.c
	psi/lcdriv.c
	psi/logger.c
	psi/logger.h
	psi/make_gen
	psi/oicom.c
	psi/oicom.h
	psi/psi.c
	psi/remob.c
	psi/remob.h
	psi/tecs/didi
	psi/tecs/make_crv.tcsh
	psi/tecs/make_gen
	psi/tecs/myc_buf.c
	psi/tecs/six.c
	psi/tecs/tecs.c
	psi/tecs/tecs_client.f
	psi/tecs/tecs_plot.f
	psi/tecs/term.c
	psi/tecs/pg_plus/xwdriv.c
This commit is contained in:
cvs
2004-11-17 11:32:05 +00:00
parent 075fa10e23
commit 0727dc195d
16 changed files with 244 additions and 97 deletions

View File

@ -83,7 +83,8 @@
self->start = time(NULL);
self->lastt = 0;
self->iWarned = 0;
SCSave(&self->conn, pCon);
/* try at least three times to do it */
for(i = 0; i < 3; i++)
{
@ -178,9 +179,10 @@
float fPos, fDelta;
int iRet, iCode, iFix;
char pBueffel[256], pError[132];
static int callCount, iCount=0;
static int callCount;
time_t now, tmo;
float tol;
self = (pEVControl)pData;
assert(self);
assert(pCon);
@ -254,13 +256,12 @@
self->eMode = EVMonitor;
return HWIdle;
}
if(fDelta <= ObVal(self->pParam, TOLERANCE)) /* done */
tol = ObVal(self->pParam, TOLERANCE);
if (self->lastt > 0) { /* increase tol for hysteresis */
tol=tol*1.1001;
}
if(fDelta <= tol) /* inside tolerance */
{
if (iCount < 3)
{
iCount++;
return HWBusy;
}
tmo = (int)(ObVal(self->pParam, SETTLE));
if (self->lastt <= 0) /* lastt negative: -seconds already waited */
{
@ -282,10 +283,6 @@
}
else
{
if (iCount > 0) {
iCount--;
return HWBusy;
}
if (self->lastt > 0) { /* save time already waited */
sprintf(pBueffel,"%s outside tolerance, settling time suspended",
self->pName);
@ -341,7 +338,7 @@
}
/*---------------------------- Error Handlers --------------------------------*/
static void ErrWrite(char *txt)
static void ErrWrite(char *txt, SCStore *conn)
{
pExeList pExe;
SConnection *pCon = NULL;
@ -349,6 +346,10 @@ static void ErrWrite(char *txt)
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
if (!pCon)
{
pCon = SCLoad(conn);
}
if(pCon)
{
SCWrite(pCon,txt,eWarning);
@ -369,7 +370,7 @@ static void ErrReport(pEVControl self)
{
sprintf(pBueffel,"WARNING: %s is out of range by %g",
self->pName,fDelta);
ErrWrite(pBueffel);
ErrWrite(pBueffel, &self->conn);
self->iWarned = 1;
}
}
@ -442,7 +443,7 @@ static void ErrReport(pEVControl self)
snprintf(pBueffel,255,
"ERROR: %s while processing errorscript for %s",
pTcl->result,self->pName);
ErrWrite(pBueffel);
ErrWrite(pBueffel, &self->conn);
}
/*
assume that everything is fine again after the script
@ -456,7 +457,7 @@ static void ErrReport(pEVControl self)
snprintf(pBueffel,255,
"ERROR: script error handling requested for %s, but no script given",
self->pName);
ErrWrite(pBueffel);
ErrWrite(pBueffel, &self->conn);
}
return 1;
@ -486,7 +487,7 @@ static void ErrReport(pEVControl self)
ErrReport(self);
ErrWrite("Running to safe value");
ErrWrite("Running to safe value", &self->conn);
self->pDriv->SetValue(self->pDriv, ObVal(self->pParam,SAFEVALUE));
self->eMode = EVIdle;
self->iWarned = 0;
@ -552,7 +553,8 @@ static void ErrReport(pEVControl self)
char pError[10], pBueffel[512];
pExeList pExe = NULL;
SConnection *pCon = NULL;
float tol;
self = (pEVControl)pData;
assert(self);
@ -568,23 +570,16 @@ static void ErrReport(pEVControl self)
{
fDelta = -fDelta;
}
if(fDelta < ObVal(self->pParam,TOLERANCE))
tol = ObVal(self->pParam,TOLERANCE);
if (self->iWarned == 0) tol=tol*1.1001;
if(fDelta <= tol)
{
self->eMode = EVMonitor;
if(self->iWarned)
{
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
sprintf(pBueffel,"Environment device %s back in tolerances again",
self->pName);
if(pCon)
{
SCWrite(pCon,pBueffel,eWarning);
}
else
{
ServerWriteGlobal(pBueffel,eWarning);
}
ErrWrite(pBueffel, &self->conn);
self->iWarned = 0;
}
return 1;
@ -684,6 +679,7 @@ static void ErrReport(pEVControl self)
return NULL;
}
pRes->pDes->GetInterface = EVIInterface;
pRes->pDes->SaveStatus = EVSaveStatus;
/* new Drivable interface */
pRes->pDrivInt = CreateDrivableInterface();
@ -738,7 +734,7 @@ static void ErrReport(pEVControl self)
ObParInit(pRes->pParam, ERRORHANDLER, "errorhandler", 0.0, usUser);
ObParInit(pRes->pParam, INTERRUPT, "interrupt", eContinue, usUser);
ObParInit(pRes->pParam, UPLIMIT, "upperlimit", 300.0, usUser);
ObParInit(pRes->pParam, LOWLIMIT, "lowerlimit", 2., usUser);
ObParInit(pRes->pParam, LOWLIMIT, "lowerlimit", 1.0, usUser);
ObParInit(pRes->pParam, SAFEVALUE, "safevalue", 0., usUser);
ObParInit(pRes->pParam, MAXWAIT, "maxwait", 0., usUser);
ObParInit(pRes->pParam, SETTLE, "settle", 0., usUser);
@ -749,11 +745,9 @@ static void ErrReport(pEVControl self)
pDriv->GetValues=StdGetValues;
}
iRet = pDriv->Init(pDriv);
if(iRet >= 0)
{
*iErr = iRet;
}
*iErr = iRet;
/* new var log for logging values */
pRes->iLog = 1;
if(!VarlogInit(&pRes->pLog))
@ -765,7 +759,7 @@ static void ErrReport(pEVControl self)
pRes->pName = strdup(pName);
pRes->eMode = EVIdle;
pRes->iWarned = 0;
/* a terminal error gives a -1 in iRet */
if(iRet < 0)
{
@ -828,6 +822,10 @@ static void ErrReport(pEVControl self)
{
free(self->errorScript);
}
if (self->creationArgs != NULL)
{
free(self->creationArgs);
}
free(self);
}
/*--------------------------------------------------------------------------*/
@ -1217,9 +1215,52 @@ static void ErrReport(pEVControl self)
return 0; /* not reached */
}
/*-----------------------------------------------------------------------*/
int EVSaveStatus(void *pData, char *name, FILE *fil)
{
pEVControl evc = pData;
if (evc->creationArgs) {
fprintf(fil, "evfactory replace %s %s\n", name, evc->creationArgs);
}
return 1;
}
/*-----------------------------------------------------------------------*/
pEVControl MakeEVController(pEVDriver pDriv, SConnection *pCon,
ObjectFunc wrapper, int argc, char *argv[])
{
pEVControl pNew;
int status = 1;
char pBueffel[512];
char pError[132];
if (pDriv == NULL) {
SCWrite(pCon,"ERROR: failed to create driver",eError);
return NULL;
}
pNew = CreateEVController(pDriv,argv[0],&status);
if (status != 1) {
SCWrite(pCon,"ERROR: failed to initialize device", eError);
pDriv->GetError(pDriv,&status,pError,sizeof pError -1);
sprintf(pBueffel,"HW reported: %s",pError);
SCWrite(pCon,pBueffel,eError);
}
if (pNew == NULL) {
SCWrite(pCon,"ERROR: failed to create environment device object",
eError);
DeleteEVDriver(pDriv);
return NULL;
}
if (wrapper == NULL) {
AddCommand(pServ->pSics,argv[0],EVControlWrapper,DeleteEVController,pNew);
} else {
AddCommand(pServ->pSics,argv[0],wrapper,DeleteEVController,pNew);
}
return pNew;
}
/*-----------------------------------------------------------------------*/
static pEVControl InstallCommonControllers(SicsInterp *pSics,
SConnection *pCon,
int argc, char *argv[])
int argc, char *argv[],
int *found)
{
pEVControl pNew = NULL;
pEVDriver pDriv = NULL;
@ -1228,6 +1269,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
int (*Wrapper)(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]) = EVControlWrapper;
*found=1;
if(strcmp(argv[3],"sim") == 0) /* SIM driver */
{
/* Create a Sim Driver */
@ -1287,7 +1329,9 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
return NULL;
}
} else {
return NULL; /* not recognized */
/* not recognized */
*found=0;
return NULL;
}
@ -1338,7 +1382,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
{
pEVControl pNew = NULL;
char pBueffel[512],pError[132];
int iRet;
int iRet, found;
CommandList *pCom = NULL;
pSite site = NULL;
@ -1382,7 +1426,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
SCSendOK(pCon);
return 1;
}
else if(strcmp(argv[1],"new") == 0) /*make a new one */
else if(strcmp(argv[1],"new") == 0 || strcmp(argv[1], "replace") == 0) /* make a new one */
{
/* argv[2] = name */
/* argv[3] must be type */
@ -1394,31 +1438,42 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
}
strtolower(argv[2]);
strtolower(argv[3]);
if (FindCommandData(pSics, argv[2], "Environment Controller")) {
if (strcmp(argv[1], "replace") == 0) {
RemoveCommand(pSics, argv[2]);
} else {
sprintf(pBueffel,
"ERROR: environment device %s already installed, delete first",
argv[2]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
}
pCom = FindCommand(pSics,argv[2]);
if(pCom)
{
sprintf(pBueffel,
"ERROR: environment device %s already installed, delete first",
argv[2]);
sprintf(pBueffel, "ERROR: command %s already exists", argv[2]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
pNew = InstallCommonControllers(pSics,pCon,argc,argv);
if(pNew == NULL)
{
pNew = InstallCommonControllers(pSics,pCon,argc,argv,&found);
if (!found) {
site = getSite();
if(site != NULL){
pNew = site->InstallEnvironmentController(pSics,pCon,argc,argv);
} else {
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type", argv[3]);
SCWrite(pCon,pBueffel,eError);
pNew = NULL;
}
if(pNew == NULL){
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type",
argv[3]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
}
if(pNew == NULL){
/* error message is already written */
return 0;
}
Arg2Text(argc-2, argv+2, pBueffel, sizeof pBueffel);
pNew->creationArgs = strdup(pBueffel);
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
pNew->driverName = strdup(argv[3]);
SCSendOK(pCon);