PSI sics-cvs-psi-complete-tree-post-site-support
This commit is contained in:
787
evcontroller.c
787
evcontroller.c
@@ -6,6 +6,14 @@
|
||||
|
||||
Mark Koennecke, Juli 1997
|
||||
|
||||
Implemented calling site specific initialisation routines.
|
||||
Mark Koennecke, July 2003
|
||||
|
||||
Implemented scripted out of tolerance handling and retrieval of
|
||||
driver name.
|
||||
Mark Koennecke, December 2003
|
||||
|
||||
|
||||
Copyright:
|
||||
|
||||
Labor fuer Neutronenstreuung
|
||||
@@ -54,23 +62,10 @@
|
||||
#include "evcontroller.i"
|
||||
#include "evdriver.i"
|
||||
#include "simev.h"
|
||||
#include "itc4.h"
|
||||
#include "dilludriv.h"
|
||||
#include "tclev.h"
|
||||
#include "bruker.h"
|
||||
#include "ltc11.h"
|
||||
#include "eurodriv.h"
|
||||
#include "el755driv.h"
|
||||
#include "A1931.h"
|
||||
#include "tecsdriv.h"
|
||||
#include "chadapter.h"
|
||||
#include "status.h"
|
||||
|
||||
/*
|
||||
from slsmagnet.c
|
||||
*/
|
||||
extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
|
||||
#include "site.h"
|
||||
/*--------------------- Functions needed to implement interfaces -----------*/
|
||||
static long EVIDrive(void *pData, SConnection *pCon, float fVal)
|
||||
{
|
||||
@@ -249,7 +244,7 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
}
|
||||
|
||||
now = time(NULL);
|
||||
tmo = (int)(ObVal(self->pParam, MAXWAIT) * 60);
|
||||
tmo = (int)(ObVal(self->pParam, MAXWAIT));
|
||||
/* based on this: logic ! */
|
||||
if (tmo>0 && now > self->start+tmo ) /* time out */
|
||||
{
|
||||
@@ -266,14 +261,14 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
iCount++;
|
||||
return HWBusy;
|
||||
}
|
||||
tmo = (int)(ObVal(self->pParam, SETTLE) * 60);
|
||||
tmo = (int)(ObVal(self->pParam, SETTLE));
|
||||
if (self->lastt <= 0) /* lastt negative: -seconds already waited */
|
||||
{
|
||||
self->lastt += now;
|
||||
if (tmo>0)
|
||||
{
|
||||
sprintf(pBueffel,"%s inside tolerance, wait %.2f min. to settle",
|
||||
self->pName, (self->lastt + tmo - now)/60.0);
|
||||
sprintf(pBueffel,"%s inside tolerance, wait %.2f sec. to settle",
|
||||
self->pName, (self->lastt + tmo - now)*1.0);
|
||||
SCWrite(pCon,pBueffel,eStatus);
|
||||
}
|
||||
return HWBusy;
|
||||
@@ -344,35 +339,45 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
|
||||
return iRes;
|
||||
}
|
||||
|
||||
/*---------------------------- Error Handlers --------------------------------*/
|
||||
static int ErrLazy(void *pData)
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
static void ErrWrite(char *txt)
|
||||
{
|
||||
pExeList pExe;
|
||||
SConnection *pCon = NULL;
|
||||
|
||||
pExe = GetExecutor();
|
||||
pCon = GetExeOwner(pExe);
|
||||
|
||||
if(pCon)
|
||||
{
|
||||
SCWrite(pCon,txt,eWarning);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerWriteGlobal(txt,eWarning);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static void ErrReport(pEVControl self)
|
||||
{
|
||||
float fPos, fDelta;
|
||||
char pBueffel[256];
|
||||
|
||||
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
|
||||
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
|
||||
ErrWrite(pBueffel);
|
||||
self->iWarned = 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int ErrLazy(void *pData)
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
|
||||
self = (pEVControl)pData;
|
||||
assert(self);
|
||||
|
||||
|
||||
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
|
||||
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
|
||||
pExe = GetExecutor();
|
||||
pCon = GetExeOwner(pExe);
|
||||
if(!self->iWarned)
|
||||
{
|
||||
if(pCon)
|
||||
{
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerWriteGlobal(pBueffel,eWarning);
|
||||
}
|
||||
}
|
||||
self->iWarned = 1;
|
||||
ErrReport(self);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -380,33 +385,14 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
pExeList pExe;
|
||||
SConnection *pCon = NULL;
|
||||
float fPos, fDelta;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
self = (pEVControl)pData;
|
||||
assert(self);
|
||||
|
||||
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
|
||||
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
|
||||
ErrReport(self);
|
||||
|
||||
pExe = GetExecutor();
|
||||
pCon = GetExeOwner(pExe);
|
||||
|
||||
if(!self->iWarned)
|
||||
{
|
||||
if(pCon)
|
||||
{
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerWriteGlobal(pBueffel,eWarning);
|
||||
}
|
||||
}
|
||||
self->iWarned = 1;
|
||||
|
||||
|
||||
if(IsCounting(pExe))
|
||||
{
|
||||
SCWrite(GetExeOwner(pExe),"Pausing till OK",eError);
|
||||
@@ -425,38 +411,59 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
ContinueExecution(pExe);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int ErrScript(void *pData)
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
int iRet;
|
||||
Tcl_Interp *pTcl = NULL;
|
||||
pExeList pExe;
|
||||
char pBueffel[256];
|
||||
|
||||
self = (pEVControl)pData;
|
||||
assert(self);
|
||||
|
||||
ErrReport(self);
|
||||
|
||||
pExe = GetExecutor();
|
||||
if(self->errorScript != NULL)
|
||||
{
|
||||
pTcl = InterpGetTcl(pServ->pSics);
|
||||
iRet = Tcl_Eval(pTcl,self->errorScript);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
snprintf(pBueffel,255,
|
||||
"ERROR: %s while processing errorscript for %s",
|
||||
pTcl->result,self->pName);
|
||||
ErrWrite(pBueffel);
|
||||
}
|
||||
/*
|
||||
assume that everything is fine again after the script
|
||||
returns
|
||||
*/
|
||||
self->eMode = EVMonitor;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(pBueffel,255,
|
||||
"ERROR: script error handling requested for %s, but no script given",
|
||||
self->pName);
|
||||
ErrWrite(pBueffel);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int ErrInterrupt(void *pData)
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
pExeList pExe;
|
||||
SConnection *pCon = NULL;
|
||||
float fPos,fDelta;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
|
||||
self = (pEVControl)pData;
|
||||
assert(self);
|
||||
|
||||
/* report problem */
|
||||
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
|
||||
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
|
||||
pExe = GetExecutor();
|
||||
pCon = GetExeOwner(pExe);
|
||||
if(!self->iWarned)
|
||||
{
|
||||
if(pCon)
|
||||
{
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerWriteGlobal(pBueffel,eWarning);
|
||||
}
|
||||
}
|
||||
self->iWarned = 1;
|
||||
ErrReport(self);
|
||||
|
||||
/* interrupt */
|
||||
SetInterrupt((int)ObVal(self->pParam,INTERRUPT));
|
||||
@@ -466,31 +473,13 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
static int ErrRun(void *pData)
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
pExeList pExe;
|
||||
SConnection *pCon = NULL;
|
||||
float fPos, fDelta;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
self = (pEVControl)pData;
|
||||
assert(self);
|
||||
|
||||
/* report problem */
|
||||
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
|
||||
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
|
||||
pExe = GetExecutor();
|
||||
pCon = GetExeOwner(pExe);
|
||||
if(pCon)
|
||||
{
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
SCWrite(pCon,"Driving to a safe place",eWarning);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerWriteGlobal(pBueffel,eWarning);
|
||||
ServerWriteGlobal("Driving to a safe place",eWarning);
|
||||
}
|
||||
|
||||
ErrReport(self);
|
||||
|
||||
ErrWrite("Running to safe value");
|
||||
self->pDriv->SetValue(self->pDriv, ObVal(self->pParam,SAFEVALUE));
|
||||
self->eMode = EVIdle;
|
||||
return 1;
|
||||
@@ -524,6 +513,10 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
iStatus = ErrRun(pData);
|
||||
return iStatus;
|
||||
break;
|
||||
case 4: /* invoke a script */
|
||||
iStatus = ErrScript(pData);
|
||||
return iStatus;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -820,6 +813,14 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
{
|
||||
VarlogDelete(self->pLog);
|
||||
}
|
||||
if(self->driverName != NULL)
|
||||
{
|
||||
free(self->driverName);
|
||||
}
|
||||
if(self->errorScript != NULL)
|
||||
{
|
||||
free(self->errorScript);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -948,43 +949,55 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
sprintf(pBueffel,"Parameter listing for %s",self->pName);
|
||||
snprintf(pBueffel,255,"Parameter listing for %s",self->pName);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
|
||||
sprintf(pBueffel,"%s.%s = %g ",self->pName, "tolerance",
|
||||
snprintf(pBueffel,255,"%s.%s = %g ",self->pName, "tolerance",
|
||||
ObVal(self->pParam,TOLERANCE));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "access",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "access",
|
||||
ObVal(self->pParam,ACCESS));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "ErrorHandler",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "ErrorHandler",
|
||||
ObVal(self->pParam,ERRORHANDLER));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "interrupt",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "interrupt",
|
||||
ObVal(self->pParam,INTERRUPT));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "UpperLimit",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "UpperLimit",
|
||||
ObVal(self->pParam,UPLIMIT));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "LowerLimit",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "LowerLimit",
|
||||
ObVal(self->pParam,LOWLIMIT));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "SafeValue",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "SafeValue",
|
||||
ObVal(self->pParam,SAFEVALUE));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "MaxWait",
|
||||
snprintf(pBueffel,255,"%s.%s = %g (sec)",self->pName, "MaxWait",
|
||||
ObVal(self->pParam,MAXWAIT));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "Settle",
|
||||
snprintf(pBueffel,255,"%s.%s = %g (sec)",self->pName, "Settle",
|
||||
ObVal(self->pParam,SETTLE));
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
EVCGetPos(self,pCon,&fPos);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "CurrentValue",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "CurrentValue",
|
||||
fPos);
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
sprintf(pBueffel,"%s.%s = %g",self->pName, "TargetValue",
|
||||
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "TargetValue",
|
||||
self->fTarget);
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
snprintf(pBueffel,255,"%s.driver = %s",self->pName, self->driverName);
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
if(self->errorScript != NULL)
|
||||
{
|
||||
snprintf(pBueffel,255,"%s.errorScript = %s", self->pName,
|
||||
self->errorScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(pBueffel,255,"%s.errorScript = UNDEFINED", self->pName);
|
||||
}
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1122,6 +1135,35 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
}
|
||||
else /* parameter request */
|
||||
{
|
||||
/*
|
||||
catch case of errorScript
|
||||
*/
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"errorscript") == 0)
|
||||
{
|
||||
if(self->errorScript != NULL)
|
||||
{
|
||||
snprintf(pBueffel,255,"%s.errorScript = %s",self->pName,
|
||||
self->errorScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(pBueffel,255,"%s.errorScript = UNDEFINED",
|
||||
self->pName);
|
||||
}
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
catch case for drivername
|
||||
*/
|
||||
if(strcmp(argv[1],"driver") == 0)
|
||||
{
|
||||
snprintf(pBueffel,255,"%s.driver = %s", self->pName,
|
||||
self->driverName);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
iRet = EVCGetPar(self,argv[1],&fPos);
|
||||
if(!iRet)
|
||||
{
|
||||
@@ -1140,6 +1182,21 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
}
|
||||
else /* try to set parameter */
|
||||
{
|
||||
/*
|
||||
first catch case of errorScript
|
||||
*/
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"errorscript") == 0)
|
||||
{
|
||||
Arg2Text(argc-2,&argv[2],pBueffel,255);
|
||||
if(self->errorScript != NULL)
|
||||
{
|
||||
free(self->errorScript);
|
||||
}
|
||||
self->errorScript = strdup(pBueffel);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
@@ -1156,6 +1213,114 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
}
|
||||
return 0; /* not reached */
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
||||
SConnection *pCon,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pEVControl pNew = NULL;
|
||||
pEVDriver pDriv = NULL;
|
||||
char pBueffel[512],pError[132];
|
||||
int iRet;
|
||||
int (*Wrapper)(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]) = EVControlWrapper;
|
||||
|
||||
if(strcmp(argv[3],"sim") == 0) /* SIM driver */
|
||||
{
|
||||
/* Create a Sim Driver */
|
||||
pDriv = CreateSIMEVDriver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create Environment Device driver",
|
||||
eError);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[3],"tcl") == 0) /* Tcl driver */
|
||||
{
|
||||
/* Create a Tcl driver */
|
||||
pDriv = CreateTclDriver(argc-4,&argv[4],argv[2], pCon);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create TCL device driver",eError);
|
||||
return NULL;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
DeleteEVDriver(pDriv);
|
||||
return NULL;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
Wrapper = TclEnvironmentWrapper;
|
||||
pNew->iTcl = 1;
|
||||
/* make ev parameters available to Tcl */
|
||||
UpdateTclVariable(pNew->pDriv,"tolerance",
|
||||
ObVal(pNew->pParam,TOLERANCE));
|
||||
UpdateTclVariable(pNew->pDriv,"upperlimit",
|
||||
ObVal(pNew->pParam,UPLIMIT));
|
||||
UpdateTclVariable(pNew->pDriv,"lowerlimit",
|
||||
ObVal(pNew->pParam,LOWLIMIT));
|
||||
}
|
||||
else if(strcmp(argv[3],"gencon") == 0) /* general controller */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = MakeControllerEnvironmentDriver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create Controller Environment driver",
|
||||
eError);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL; /* not recognized */
|
||||
}
|
||||
|
||||
|
||||
if(pNew == NULL) /* not yet initialized */
|
||||
{
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
DeleteEVDriver(pDriv);
|
||||
return NULL;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
}
|
||||
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],Wrapper,
|
||||
DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",
|
||||
argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return NULL;
|
||||
}
|
||||
return pNew;
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
EVControlFactory implements a SICS command which creates and deletes
|
||||
Controllers at run-time. Syntax:
|
||||
@@ -1169,10 +1334,10 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pEVControl pNew = NULL;
|
||||
pEVDriver pDriv = NULL;
|
||||
char pBueffel[512],pError[132];
|
||||
int iRet;
|
||||
CommandList *pCom = NULL;
|
||||
pSite site = NULL;
|
||||
|
||||
assert(pSics);
|
||||
assert(pCon);
|
||||
@@ -1229,384 +1394,30 @@ extern pEVDriver CreateSLSDriv(int argc, char *argv[]);
|
||||
pCom = FindCommand(pSics,argv[2]);
|
||||
if(pCom)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: environment device %s already installed, delete first",
|
||||
sprintf(pBueffel,
|
||||
"ERROR: environment device %s already installed, delete first",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(argv[3],"sim") == 0) /* SIM driver */
|
||||
pNew = InstallCommonControllers(pSics,pCon,argc,argv);
|
||||
if(pNew == NULL)
|
||||
{
|
||||
/* Create a Sim Driver */
|
||||
|
||||
pDriv = CreateSIMEVDriver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create Environment Device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
site = getSite();
|
||||
if(site != NULL){
|
||||
pNew = site->InstallEnvironmentController(pSics,pCon,argc,argv);
|
||||
} else {
|
||||
pNew = NULL;
|
||||
}
|
||||
if(pNew == NULL){
|
||||
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type",
|
||||
argv[3]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[3],"tecs") == 0) /* TECS temperature server */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateTecsDriver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create TECS device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to initialize Tecs",eError);
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
/* set a few parameters */
|
||||
EVCSetPar(pNew,"upperlimit",300.0,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",1.0,pCon);
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],TecsWrapper,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[3],"itc4") == 0) /* ITC4 driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateITC4Driver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create ITC4 device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
/* set a few parameters */
|
||||
EVCSetPar(pNew,"upperlimit",300.0,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",1.0,pCon);
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],ITC4Wrapper,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[3],"bruker") == 0) /* Bruker Magnet Controller driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateBrukerDriver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create Bruker Controller device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
|
||||
/* set a few parameters */
|
||||
EVCSetPar(pNew,"upperlimit",45.0,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",0.0,pCon);
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],BrukerAction,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[3],"ltc11") == 0)
|
||||
/* Neocera LTC-11 temperature controller*/
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateLTC11Driver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create LTC-11 device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
/* set a few parameters */
|
||||
EVCSetPar(pNew,"upperlimit",500.,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",1.5,pCon);
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],LTC11Action,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}else if(strcmp(argv[3],"a1931") == 0)
|
||||
/* Risoe A1931 temperature controller*/
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateA1931Driver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create A1931 device driver",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],A1931Action,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[3],"tcl") == 0) /* Tcl driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateTclDriver(argc-4,&argv[4],argv[2], pCon);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to create TCL device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
DeleteEVDriver(pDriv);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],TclEnvironmentWrapper,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
pNew->iTcl = 1;
|
||||
/* make ev parameters available to Tcl */
|
||||
UpdateTclVariable(pNew->pDriv,"tolerance",
|
||||
ObVal(pNew->pParam,TOLERANCE));
|
||||
UpdateTclVariable(pNew->pDriv,"upperlimit",
|
||||
ObVal(pNew->pParam,UPLIMIT));
|
||||
UpdateTclVariable(pNew->pDriv,"lowerlimit",
|
||||
ObVal(pNew->pParam,LOWLIMIT));
|
||||
|
||||
/* register controller for monitoring */
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[3],"dillu") == 0) /* dillution driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateDILLUDriv(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create Dillution device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[3],"gencon") == 0) /* general controller */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = MakeControllerEnvironmentDriver(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create Controller Environment driver",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[3],"euro") == 0) /* dillution driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateEURODriv(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create Eurotherm device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[3],"psi-dsp") == 0) /* PSI-DSP magnet driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateSLSDriv(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create PSI-DSP device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[3],"el755") == 0) /* EL755 magnet driver */
|
||||
{
|
||||
/* Create a driver */
|
||||
pDriv = CreateEL755Driv(argc-4,&argv[4]);
|
||||
if(!pDriv)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: failed to create EL755 device driver",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type",
|
||||
argv[3]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
/* got a driver, initialise everything */
|
||||
pNew = CreateEVController(pDriv,argv[2],&iRet);
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR creating Environment Controller",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: problem initialising Environment controller",
|
||||
eError);
|
||||
pDriv->GetError(pDriv,&iRet,pError,131);
|
||||
sprintf(pBueffel,"HW reported: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
|
||||
/* set a few parameters */
|
||||
if(strcmp(argv[3],"euro") == 0)
|
||||
{
|
||||
EVCSetPar(pNew,"upperlimit",750.0,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",15.0,pCon);
|
||||
}
|
||||
else if(strcmp(argv[3],"el755") == 0)
|
||||
{
|
||||
EVCSetPar(pNew,"upperlimit",10.,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",-10.,pCon);
|
||||
}
|
||||
else
|
||||
{
|
||||
EVCSetPar(pNew,"upperlimit",4.0,pCon);
|
||||
EVCSetPar(pNew,"lowerlimit",0.05,pCon);
|
||||
}
|
||||
/* install command */
|
||||
iRet = AddCommand(pSics,argv[2],EVControlWrapper,DeleteEVController,
|
||||
pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[2]);
|
||||
DeleteEVController((void *)pNew);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||
pNew->driverName = strdup(argv[3]);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user