- made fixes to hkl

- Introduced a help system
- introduced a module for handling automatic updates of files during
  long measurements
- Added a circular buffer and handling facilities to varlog
- Upgraded documentation


SKIPPED:
	psi/faverage.h
	psi/nxamor.tex
	psi/pimotor.h
	psi/pimotor.tex
This commit is contained in:
cvs
2003-12-10 13:50:44 +00:00
parent 7a5f0193ab
commit bc02cb79e7
80 changed files with 2680 additions and 664 deletions

View File

@ -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
@ -331,35 +339,45 @@
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;
}
/*--------------------------------------------------------------------------*/
@ -367,33 +385,14 @@
{
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);
@ -412,38 +411,59 @@
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));
@ -453,31 +473,13 @@
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;
@ -511,6 +513,10 @@
iStatus = ErrRun(pData);
return iStatus;
break;
case 4: /* invoke a script */
iStatus = ErrScript(pData);
return iStatus;
break;
default:
return 0;
@ -807,6 +813,14 @@
{
VarlogDelete(self->pLog);
}
if(self->driverName != NULL)
{
free(self->driverName);
}
if(self->errorScript != NULL)
{
free(self->errorScript);
}
free(self);
}
/*--------------------------------------------------------------------------*/
@ -935,43 +949,55 @@
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",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",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;
}
@ -1109,6 +1135,35 @@
}
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)
{
@ -1127,6 +1182,21 @@
}
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)
{
@ -1346,7 +1416,8 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
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;
}