- 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:
93
devexec.c
93
devexec.c
@ -105,6 +105,7 @@
|
|||||||
long lTask;
|
long lTask;
|
||||||
pTaskMan pTask;
|
pTaskMan pTask;
|
||||||
int iLock;
|
int iLock;
|
||||||
|
pICallBack pCall;
|
||||||
} ExeList;
|
} ExeList;
|
||||||
|
|
||||||
static pExeList pExecutor = NULL;
|
static pExeList pExecutor = NULL;
|
||||||
@ -139,6 +140,7 @@
|
|||||||
pRes->pTask = pTask;
|
pRes->pTask = pTask;
|
||||||
pRes->lTask = -1;
|
pRes->lTask = -1;
|
||||||
pRes->iLock = 0;
|
pRes->iLock = 0;
|
||||||
|
pRes->pCall = CreateCallBackInterface();
|
||||||
return pRes;
|
return pRes;
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@ -153,9 +155,21 @@
|
|||||||
DeleteDescriptor(self->pDes);
|
DeleteDescriptor(self->pDes);
|
||||||
ClearExecutor(self);
|
ClearExecutor(self);
|
||||||
LLDdelete(self->iList);
|
LLDdelete(self->iList);
|
||||||
|
if(self->pCall)
|
||||||
|
DeleteCallBackInterface(self->pCall);
|
||||||
|
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
void ExeInterest(pExeList self, pDevEntry pDev, char *text) {
|
||||||
|
char buf[128];
|
||||||
|
|
||||||
|
if(pDev)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf),"%s %s",pDev->name,text);
|
||||||
|
InvokeCallBack(self->pCall, DRIVSTAT, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
|
int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
|
||||||
void *pData, SConnection *pCon, float fNew)
|
void *pData, SConnection *pCon, float fNew)
|
||||||
@ -220,6 +234,7 @@
|
|||||||
if(iRet == OKOK)
|
if(iRet == OKOK)
|
||||||
{
|
{
|
||||||
LLDnodeAppendFrom(self->iList,&pNew);
|
LLDnodeAppendFrom(self->iList,&pNew);
|
||||||
|
ExeInterest(self, pNew, "started");
|
||||||
self->iRun = 1;
|
self->iRun = 1;
|
||||||
self->iStatus = DEVDONE;
|
self->iStatus = DEVDONE;
|
||||||
/* if no task: start it */
|
/* if no task: start it */
|
||||||
@ -388,6 +403,7 @@
|
|||||||
{
|
{
|
||||||
pDrivInt->iErrorCount = 0;
|
pDrivInt->iErrorCount = 0;
|
||||||
}
|
}
|
||||||
|
ExeInterest(self, pDev, "finished");
|
||||||
DeleteDevEntry(pDev);
|
DeleteDevEntry(pDev);
|
||||||
LLDnodeDelete(self->iList);
|
LLDnodeDelete(self->iList);
|
||||||
iRet = LLDnodePtr2Prev(self->iList);
|
iRet = LLDnodePtr2Prev(self->iList);
|
||||||
@ -399,6 +415,7 @@
|
|||||||
self->iStatus = DEVDONE;
|
self->iStatus = DEVDONE;
|
||||||
break;
|
break;
|
||||||
case HWFault: /* real HW error: burning, no net etc.. */
|
case HWFault: /* real HW error: burning, no net etc.. */
|
||||||
|
ExeInterest(self, pDev, "finished with problem");
|
||||||
DeleteDevEntry(pDev);
|
DeleteDevEntry(pDev);
|
||||||
LLDnodeDelete(self->iList);
|
LLDnodeDelete(self->iList);
|
||||||
self->iStatus = DEVERROR;
|
self->iStatus = DEVERROR;
|
||||||
@ -446,6 +463,7 @@
|
|||||||
self->iStatus = DEVBUSY;
|
self->iStatus = DEVBUSY;
|
||||||
break;
|
break;
|
||||||
case HWPosFault: /* cannot get somewhere... */
|
case HWPosFault: /* cannot get somewhere... */
|
||||||
|
ExeInterest(self, pDev, "finished with problem");
|
||||||
DeleteDevEntry(pDev);
|
DeleteDevEntry(pDev);
|
||||||
LLDnodeDelete(self->iList);
|
LLDnodeDelete(self->iList);
|
||||||
self->iStatus = DEVERROR;
|
self->iStatus = DEVERROR;
|
||||||
@ -561,23 +579,23 @@
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
check for stop flag. This is to stop unnecessary calls to StopExe.
|
|
||||||
There may be way to many, but each call is reasonable under certain
|
|
||||||
circumstances.
|
|
||||||
*/
|
|
||||||
if(self->iStop == 1)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
self->iStop = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* first the ALL case */
|
/* first the ALL case */
|
||||||
if(strcmp(name,"all") == 0)
|
if(strcmp(name,"all") == 0)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
check for stop flag. This is to stop unnecessary calls to StopExe.
|
||||||
|
There may be way to many, but each call is reasonable under certain
|
||||||
|
circumstances.
|
||||||
|
*/
|
||||||
|
if(self->iStop == 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->iStop = 1;
|
||||||
|
}
|
||||||
|
|
||||||
iRet = LLDnodePtr2First(self->iList);
|
iRet = LLDnodePtr2First(self->iList);
|
||||||
while(iRet != 0)
|
while(iRet != 0)
|
||||||
{
|
{
|
||||||
@ -796,12 +814,48 @@
|
|||||||
SCWrite(pCon,pBueffel,eError);
|
SCWrite(pCon,pBueffel,eError);
|
||||||
}
|
}
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
/*------------------- The CallBack function for interest ------------------*/
|
||||||
|
static int DrivStatCallback(int iEvent, void *text, void *pCon)
|
||||||
|
{
|
||||||
|
assert(pCon);
|
||||||
|
assert(text);
|
||||||
|
|
||||||
|
SCWrite(pCon, text, eValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
int ListExe(SConnection *pCon, SicsInterp *pSics, void *pData,
|
int ListExe(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
return ListPending((pExeList)pData,pCon);
|
pExeList self = NULL;
|
||||||
|
int list;
|
||||||
|
|
||||||
|
if (argc == 1) {
|
||||||
|
return ListPending((pExeList)pData,pCon);
|
||||||
|
}
|
||||||
|
argtolower(argc,argv);
|
||||||
|
self = (pExeList)pData;
|
||||||
|
assert(self);
|
||||||
|
if (argc == 2) {
|
||||||
|
if (strcmp(argv[1], "interest") == 0)
|
||||||
|
{
|
||||||
|
list = RegisterCallback(self->pCall, DRIVSTAT, DrivStatCallback,
|
||||||
|
pCon, NULL);
|
||||||
|
SCRegister(pCon, pSics, self->pCall,list);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (strcmp(argv[1], "uninterest") == 0)
|
||||||
|
{
|
||||||
|
RemoveCallback2(self->pCall, pCon);
|
||||||
|
SCUnregister(pCon, self->pCall);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SCWrite(pCon, "ERROR: illegal arguments for ListExe", eError);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
Usage:
|
Usage:
|
||||||
@ -927,12 +981,17 @@
|
|||||||
iInterrupt = SCGetInterrupt(self->pOwner);
|
iInterrupt = SCGetInterrupt(self->pOwner);
|
||||||
if(iInterrupt != eContinue)
|
if(iInterrupt != eContinue)
|
||||||
{
|
{
|
||||||
SCWrite(self->pOwner,pBueffel, eError);
|
|
||||||
if(iInterrupt > 1)
|
if(iInterrupt > 1)
|
||||||
{
|
{
|
||||||
|
/* M.Z: it seems that this warning is redundant
|
||||||
|
a) because it was erroenous
|
||||||
|
b) it would be emitted for every driveable obj to be stopped
|
||||||
|
|
||||||
Interrupt2Text(iInterrupt,pInterrupt,79);
|
Interrupt2Text(iInterrupt,pInterrupt,79);
|
||||||
snprintf(pBueffel,131,"ERROR: interrupt %s triggered",
|
snprintf(pBueffel,131,"ERROR: interrupt %s triggered",
|
||||||
pInterrupt);
|
pInterrupt);
|
||||||
|
SCWrite(self->pOwner,pBueffel, eError);
|
||||||
|
*/
|
||||||
StopExe(self,"all");
|
StopExe(self,"all");
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
161
evcontroller.c
161
evcontroller.c
@ -83,7 +83,8 @@
|
|||||||
self->start = time(NULL);
|
self->start = time(NULL);
|
||||||
self->lastt = 0;
|
self->lastt = 0;
|
||||||
self->iWarned = 0;
|
self->iWarned = 0;
|
||||||
|
SCSave(&self->conn, pCon);
|
||||||
|
|
||||||
/* try at least three times to do it */
|
/* try at least three times to do it */
|
||||||
for(i = 0; i < 3; i++)
|
for(i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
@ -178,9 +179,10 @@
|
|||||||
float fPos, fDelta;
|
float fPos, fDelta;
|
||||||
int iRet, iCode, iFix;
|
int iRet, iCode, iFix;
|
||||||
char pBueffel[256], pError[132];
|
char pBueffel[256], pError[132];
|
||||||
static int callCount, iCount=0;
|
static int callCount;
|
||||||
time_t now, tmo;
|
time_t now, tmo;
|
||||||
|
float tol;
|
||||||
|
|
||||||
self = (pEVControl)pData;
|
self = (pEVControl)pData;
|
||||||
assert(self);
|
assert(self);
|
||||||
assert(pCon);
|
assert(pCon);
|
||||||
@ -254,13 +256,12 @@
|
|||||||
self->eMode = EVMonitor;
|
self->eMode = EVMonitor;
|
||||||
return HWIdle;
|
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));
|
tmo = (int)(ObVal(self->pParam, SETTLE));
|
||||||
if (self->lastt <= 0) /* lastt negative: -seconds already waited */
|
if (self->lastt <= 0) /* lastt negative: -seconds already waited */
|
||||||
{
|
{
|
||||||
@ -282,10 +283,6 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iCount > 0) {
|
|
||||||
iCount--;
|
|
||||||
return HWBusy;
|
|
||||||
}
|
|
||||||
if (self->lastt > 0) { /* save time already waited */
|
if (self->lastt > 0) { /* save time already waited */
|
||||||
sprintf(pBueffel,"%s outside tolerance, settling time suspended",
|
sprintf(pBueffel,"%s outside tolerance, settling time suspended",
|
||||||
self->pName);
|
self->pName);
|
||||||
@ -341,7 +338,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------- Error Handlers --------------------------------*/
|
/*---------------------------- Error Handlers --------------------------------*/
|
||||||
static void ErrWrite(char *txt)
|
static void ErrWrite(char *txt, SCStore *conn)
|
||||||
{
|
{
|
||||||
pExeList pExe;
|
pExeList pExe;
|
||||||
SConnection *pCon = NULL;
|
SConnection *pCon = NULL;
|
||||||
@ -349,6 +346,10 @@ static void ErrWrite(char *txt)
|
|||||||
pExe = GetExecutor();
|
pExe = GetExecutor();
|
||||||
pCon = GetExeOwner(pExe);
|
pCon = GetExeOwner(pExe);
|
||||||
|
|
||||||
|
if (!pCon)
|
||||||
|
{
|
||||||
|
pCon = SCLoad(conn);
|
||||||
|
}
|
||||||
if(pCon)
|
if(pCon)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,txt,eWarning);
|
SCWrite(pCon,txt,eWarning);
|
||||||
@ -369,7 +370,7 @@ static void ErrReport(pEVControl self)
|
|||||||
{
|
{
|
||||||
sprintf(pBueffel,"WARNING: %s is out of range by %g",
|
sprintf(pBueffel,"WARNING: %s is out of range by %g",
|
||||||
self->pName,fDelta);
|
self->pName,fDelta);
|
||||||
ErrWrite(pBueffel);
|
ErrWrite(pBueffel, &self->conn);
|
||||||
self->iWarned = 1;
|
self->iWarned = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -442,7 +443,7 @@ static void ErrReport(pEVControl self)
|
|||||||
snprintf(pBueffel,255,
|
snprintf(pBueffel,255,
|
||||||
"ERROR: %s while processing errorscript for %s",
|
"ERROR: %s while processing errorscript for %s",
|
||||||
pTcl->result,self->pName);
|
pTcl->result,self->pName);
|
||||||
ErrWrite(pBueffel);
|
ErrWrite(pBueffel, &self->conn);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
assume that everything is fine again after the script
|
assume that everything is fine again after the script
|
||||||
@ -456,7 +457,7 @@ static void ErrReport(pEVControl self)
|
|||||||
snprintf(pBueffel,255,
|
snprintf(pBueffel,255,
|
||||||
"ERROR: script error handling requested for %s, but no script given",
|
"ERROR: script error handling requested for %s, but no script given",
|
||||||
self->pName);
|
self->pName);
|
||||||
ErrWrite(pBueffel);
|
ErrWrite(pBueffel, &self->conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -486,7 +487,7 @@ static void ErrReport(pEVControl self)
|
|||||||
|
|
||||||
ErrReport(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->pDriv->SetValue(self->pDriv, ObVal(self->pParam,SAFEVALUE));
|
||||||
self->eMode = EVIdle;
|
self->eMode = EVIdle;
|
||||||
self->iWarned = 0;
|
self->iWarned = 0;
|
||||||
@ -552,7 +553,8 @@ static void ErrReport(pEVControl self)
|
|||||||
char pError[10], pBueffel[512];
|
char pError[10], pBueffel[512];
|
||||||
pExeList pExe = NULL;
|
pExeList pExe = NULL;
|
||||||
SConnection *pCon = NULL;
|
SConnection *pCon = NULL;
|
||||||
|
float tol;
|
||||||
|
|
||||||
self = (pEVControl)pData;
|
self = (pEVControl)pData;
|
||||||
assert(self);
|
assert(self);
|
||||||
|
|
||||||
@ -568,23 +570,16 @@ static void ErrReport(pEVControl self)
|
|||||||
{
|
{
|
||||||
fDelta = -fDelta;
|
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;
|
self->eMode = EVMonitor;
|
||||||
if(self->iWarned)
|
if(self->iWarned)
|
||||||
{
|
{
|
||||||
pExe = GetExecutor();
|
|
||||||
pCon = GetExeOwner(pExe);
|
|
||||||
sprintf(pBueffel,"Environment device %s back in tolerances again",
|
sprintf(pBueffel,"Environment device %s back in tolerances again",
|
||||||
self->pName);
|
self->pName);
|
||||||
if(pCon)
|
ErrWrite(pBueffel, &self->conn);
|
||||||
{
|
|
||||||
SCWrite(pCon,pBueffel,eWarning);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ServerWriteGlobal(pBueffel,eWarning);
|
|
||||||
}
|
|
||||||
self->iWarned = 0;
|
self->iWarned = 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -684,6 +679,7 @@ static void ErrReport(pEVControl self)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pRes->pDes->GetInterface = EVIInterface;
|
pRes->pDes->GetInterface = EVIInterface;
|
||||||
|
pRes->pDes->SaveStatus = EVSaveStatus;
|
||||||
|
|
||||||
/* new Drivable interface */
|
/* new Drivable interface */
|
||||||
pRes->pDrivInt = CreateDrivableInterface();
|
pRes->pDrivInt = CreateDrivableInterface();
|
||||||
@ -738,7 +734,7 @@ static void ErrReport(pEVControl self)
|
|||||||
ObParInit(pRes->pParam, ERRORHANDLER, "errorhandler", 0.0, usUser);
|
ObParInit(pRes->pParam, ERRORHANDLER, "errorhandler", 0.0, usUser);
|
||||||
ObParInit(pRes->pParam, INTERRUPT, "interrupt", eContinue, usUser);
|
ObParInit(pRes->pParam, INTERRUPT, "interrupt", eContinue, usUser);
|
||||||
ObParInit(pRes->pParam, UPLIMIT, "upperlimit", 300.0, 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, SAFEVALUE, "safevalue", 0., usUser);
|
||||||
ObParInit(pRes->pParam, MAXWAIT, "maxwait", 0., usUser);
|
ObParInit(pRes->pParam, MAXWAIT, "maxwait", 0., usUser);
|
||||||
ObParInit(pRes->pParam, SETTLE, "settle", 0., usUser);
|
ObParInit(pRes->pParam, SETTLE, "settle", 0., usUser);
|
||||||
@ -749,11 +745,9 @@ static void ErrReport(pEVControl self)
|
|||||||
pDriv->GetValues=StdGetValues;
|
pDriv->GetValues=StdGetValues;
|
||||||
}
|
}
|
||||||
iRet = pDriv->Init(pDriv);
|
iRet = pDriv->Init(pDriv);
|
||||||
if(iRet >= 0)
|
|
||||||
{
|
*iErr = iRet;
|
||||||
*iErr = iRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* new var log for logging values */
|
/* new var log for logging values */
|
||||||
pRes->iLog = 1;
|
pRes->iLog = 1;
|
||||||
if(!VarlogInit(&pRes->pLog))
|
if(!VarlogInit(&pRes->pLog))
|
||||||
@ -765,7 +759,7 @@ static void ErrReport(pEVControl self)
|
|||||||
pRes->pName = strdup(pName);
|
pRes->pName = strdup(pName);
|
||||||
pRes->eMode = EVIdle;
|
pRes->eMode = EVIdle;
|
||||||
pRes->iWarned = 0;
|
pRes->iWarned = 0;
|
||||||
|
|
||||||
/* a terminal error gives a -1 in iRet */
|
/* a terminal error gives a -1 in iRet */
|
||||||
if(iRet < 0)
|
if(iRet < 0)
|
||||||
{
|
{
|
||||||
@ -828,6 +822,10 @@ static void ErrReport(pEVControl self)
|
|||||||
{
|
{
|
||||||
free(self->errorScript);
|
free(self->errorScript);
|
||||||
}
|
}
|
||||||
|
if (self->creationArgs != NULL)
|
||||||
|
{
|
||||||
|
free(self->creationArgs);
|
||||||
|
}
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@ -1217,9 +1215,52 @@ static void ErrReport(pEVControl self)
|
|||||||
return 0; /* not reached */
|
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,
|
static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
||||||
SConnection *pCon,
|
SConnection *pCon,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[],
|
||||||
|
int *found)
|
||||||
{
|
{
|
||||||
pEVControl pNew = NULL;
|
pEVControl pNew = NULL;
|
||||||
pEVDriver pDriv = NULL;
|
pEVDriver pDriv = NULL;
|
||||||
@ -1228,6 +1269,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
|||||||
int (*Wrapper)(SConnection *pCon, SicsInterp *pSics, void *pData,
|
int (*Wrapper)(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
int argc, char *argv[]) = EVControlWrapper;
|
int argc, char *argv[]) = EVControlWrapper;
|
||||||
|
|
||||||
|
*found=1;
|
||||||
if(strcmp(argv[3],"sim") == 0) /* SIM driver */
|
if(strcmp(argv[3],"sim") == 0) /* SIM driver */
|
||||||
{
|
{
|
||||||
/* Create a Sim Driver */
|
/* Create a Sim Driver */
|
||||||
@ -1287,7 +1329,9 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return NULL; /* not recognized */
|
/* not recognized */
|
||||||
|
*found=0;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1338,7 +1382,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
|||||||
{
|
{
|
||||||
pEVControl pNew = NULL;
|
pEVControl pNew = NULL;
|
||||||
char pBueffel[512],pError[132];
|
char pBueffel[512],pError[132];
|
||||||
int iRet;
|
int iRet, found;
|
||||||
CommandList *pCom = NULL;
|
CommandList *pCom = NULL;
|
||||||
pSite site = NULL;
|
pSite site = NULL;
|
||||||
|
|
||||||
@ -1382,7 +1426,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
|||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
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[2] = name */
|
||||||
/* argv[3] must be type */
|
/* argv[3] must be type */
|
||||||
@ -1394,31 +1438,42 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
|
|||||||
}
|
}
|
||||||
strtolower(argv[2]);
|
strtolower(argv[2]);
|
||||||
strtolower(argv[3]);
|
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]);
|
pCom = FindCommand(pSics,argv[2]);
|
||||||
if(pCom)
|
if(pCom)
|
||||||
{
|
{
|
||||||
sprintf(pBueffel,
|
sprintf(pBueffel, "ERROR: command %s already exists", argv[2]);
|
||||||
"ERROR: environment device %s already installed, delete first",
|
|
||||||
argv[2]);
|
|
||||||
SCWrite(pCon,pBueffel,eError);
|
SCWrite(pCon,pBueffel,eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pNew = InstallCommonControllers(pSics,pCon,argc,argv);
|
pNew = InstallCommonControllers(pSics,pCon,argc,argv,&found);
|
||||||
if(pNew == NULL)
|
if (!found) {
|
||||||
{
|
|
||||||
site = getSite();
|
site = getSite();
|
||||||
if(site != NULL){
|
if(site != NULL){
|
||||||
pNew = site->InstallEnvironmentController(pSics,pCon,argc,argv);
|
pNew = site->InstallEnvironmentController(pSics,pCon,argc,argv);
|
||||||
} else {
|
} else {
|
||||||
|
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type", argv[3]);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
pNew = NULL;
|
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);
|
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
|
||||||
pNew->driverName = strdup(argv[3]);
|
pNew->driverName = strdup(argv[3]);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#line 222 "evcontroller.w"
|
#line 226 "evcontroller.w"
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
E N V I R O N M E N T C O N T R O L L E R
|
E N V I R O N M E N T C O N T R O L L E R
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#define SICSEVCONTROL
|
#define SICSEVCONTROL
|
||||||
#include "varlog.h"
|
#include "varlog.h"
|
||||||
|
|
||||||
#line 144 "evcontroller.w"
|
#line 146 "evcontroller.w"
|
||||||
|
|
||||||
/*--------------------------- live & death --------------------------------*/
|
/*--------------------------- live & death --------------------------------*/
|
||||||
typedef struct __EVControl *pEVControl;
|
typedef struct __EVControl *pEVControl;
|
||||||
@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);
|
pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);
|
||||||
void DeleteEVController(void *pData);
|
void DeleteEVController(void *pData);
|
||||||
|
pEVControl MakeEVController(pEVDriver pDriv, SConnection *pCon,
|
||||||
|
ObjectFunc wrapper, int argc, char *argv[]);
|
||||||
|
int EVSaveStatus(void *pData, char *name, FILE *fil);
|
||||||
/*-------------------------- driving ---------------------------------*/
|
/*-------------------------- driving ---------------------------------*/
|
||||||
int EVCDrive(pEVControl self,SConnection *pCon, float fNew);
|
int EVCDrive(pEVControl self,SConnection *pCon, float fNew);
|
||||||
int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);
|
int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);
|
||||||
@ -44,6 +46,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 235 "evcontroller.w"
|
#line 239 "evcontroller.w"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#line 239 "evcontroller.w"
|
#line 243 "evcontroller.w"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
Environment controller datastructure
|
Environment controller datastructure
|
||||||
@ -41,9 +41,11 @@
|
|||||||
int iWarned;
|
int iWarned;
|
||||||
int iTcl;
|
int iTcl;
|
||||||
int iStop;
|
int iStop;
|
||||||
|
SCStore conn;
|
||||||
|
char *creationArgs;
|
||||||
void *pPrivate;
|
void *pPrivate;
|
||||||
void (*KillPrivate)(void *pData);
|
void (*KillPrivate)(void *pData);
|
||||||
} EVControl;
|
} EVControl;
|
||||||
|
|
||||||
#line 257 "evcontroller.w"
|
#line 261 "evcontroller.w"
|
||||||
|
|
||||||
|
@ -52,6 +52,8 @@ $\langle$evdata {\footnotesize ?}$\rangle\equiv$
|
|||||||
\mbox{}\verb@ int iWarned;@\\
|
\mbox{}\verb@ int iWarned;@\\
|
||||||
\mbox{}\verb@ int iTcl;@\\
|
\mbox{}\verb@ int iTcl;@\\
|
||||||
\mbox{}\verb@ int iStop;@\\
|
\mbox{}\verb@ int iStop;@\\
|
||||||
|
\mbox{}\verb@ SCStore conn;@\\
|
||||||
|
\mbox{}\verb@ char *creationArgs;@\\
|
||||||
\mbox{}\verb@ void *pPrivate;@\\
|
\mbox{}\verb@ void *pPrivate;@\\
|
||||||
\mbox{}\verb@ void (*KillPrivate)(void *pData);@\\
|
\mbox{}\verb@ void (*KillPrivate)(void *pData);@\\
|
||||||
\mbox{}\verb@ } EVControl;@\\
|
\mbox{}\verb@ } EVControl;@\\
|
||||||
@ -161,7 +163,7 @@ a drivers specific datastructure properly.
|
|||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
\subsubsection{Environment Controller Funtions}
|
\subsubsection{Environment Controller Funtions}
|
||||||
All of the functions below return 1 on success, 0 on failure if not sated
|
All of the functions below return 1 on success, 0 on failure if not stated
|
||||||
otherwise. Most functions take a pointer to an environment controller
|
otherwise. Most functions take a pointer to an environment controller
|
||||||
data structure as first parameter.
|
data structure as first parameter.
|
||||||
|
|
||||||
@ -177,7 +179,9 @@ $\langle$dvfunc {\footnotesize ?}$\rangle\equiv$
|
|||||||
\mbox{}\verb@@\\
|
\mbox{}\verb@@\\
|
||||||
\mbox{}\verb@ pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);@\\
|
\mbox{}\verb@ pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);@\\
|
||||||
\mbox{}\verb@ void DeleteEVController(void *pData);@\\
|
\mbox{}\verb@ void DeleteEVController(void *pData);@\\
|
||||||
\mbox{}\verb@@\\
|
\mbox{}\verb@ pEVControl MakeEVController(pEVDriver pDriv, SConnection *pCon,@\\
|
||||||
|
\mbox{}\verb@ ObjectFunc wrapper, int argc, char *argv[]);@\\
|
||||||
|
\mbox{}\verb@ int EVSaveStatus(void *pData, char *name, FILE *fil);@\\
|
||||||
\mbox{}\verb@/*-------------------------- driving ---------------------------------*/@\\
|
\mbox{}\verb@/*-------------------------- driving ---------------------------------*/@\\
|
||||||
\mbox{}\verb@ int EVCDrive(pEVControl self,SConnection *pCon, float fNew);@\\
|
\mbox{}\verb@ int EVCDrive(pEVControl self,SConnection *pCon, float fNew);@\\
|
||||||
\mbox{}\verb@ int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);@\\
|
\mbox{}\verb@ int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);@\\
|
||||||
|
@ -47,6 +47,8 @@ used by EVControl:
|
|||||||
int iWarned;
|
int iWarned;
|
||||||
int iTcl;
|
int iTcl;
|
||||||
int iStop;
|
int iStop;
|
||||||
|
SCStore conn;
|
||||||
|
char *creationArgs;
|
||||||
void *pPrivate;
|
void *pPrivate;
|
||||||
void (*KillPrivate)(void *pData);
|
void (*KillPrivate)(void *pData);
|
||||||
} EVControl;
|
} EVControl;
|
||||||
@ -137,7 +139,7 @@ a drivers specific datastructure properly.
|
|||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
\subsubsection{Environment Controller Funtions}
|
\subsubsection{Environment Controller Funtions}
|
||||||
All of the functions below return 1 on success, 0 on failure if not sated
|
All of the functions below return 1 on success, 0 on failure if not stated
|
||||||
otherwise. Most functions take a pointer to an environment controller
|
otherwise. Most functions take a pointer to an environment controller
|
||||||
data structure as first parameter.
|
data structure as first parameter.
|
||||||
|
|
||||||
@ -148,7 +150,9 @@ data structure as first parameter.
|
|||||||
|
|
||||||
pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);
|
pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);
|
||||||
void DeleteEVController(void *pData);
|
void DeleteEVController(void *pData);
|
||||||
|
pEVControl MakeEVController(pEVDriver pDriv, SConnection *pCon,
|
||||||
|
ObjectFunc wrapper, int argc, char *argv[]);
|
||||||
|
int EVSaveStatus(void *pData, char *name, FILE *fil);
|
||||||
/*-------------------------- driving ---------------------------------*/
|
/*-------------------------- driving ---------------------------------*/
|
||||||
int EVCDrive(pEVControl self,SConnection *pCon, float fNew);
|
int EVCDrive(pEVControl self,SConnection *pCon, float fNew);
|
||||||
int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);
|
int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(pNew,0,sizeof(EVDriver));
|
memset(pNew,0,sizeof(EVDriver));
|
||||||
pNew->GetValues=NULL; /* method will be replaced by default when NULL */
|
pNew->GetValues = NULL; /* method will be replaced by default when NULL */
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#line 260 "evcontroller.w"
|
#line 264 "evcontroller.w"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
Environment device driver datastructure
|
Environment device driver datastructure
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#define DEVREDO 2
|
#define DEVREDO 2
|
||||||
|
|
||||||
|
|
||||||
#line 85 "evcontroller.w"
|
#line 87 "evcontroller.w"
|
||||||
|
|
||||||
typedef struct __EVDriver {
|
typedef struct __EVDriver {
|
||||||
int (*SetValue)(pEVDriver self, float fNew);
|
int (*SetValue)(pEVDriver self, float fNew);
|
||||||
@ -30,7 +30,7 @@
|
|||||||
void (*KillPrivate)(void *pData);
|
void (*KillPrivate)(void *pData);
|
||||||
} EVDriver;
|
} EVDriver;
|
||||||
|
|
||||||
#line 271 "evcontroller.w"
|
#line 275 "evcontroller.w"
|
||||||
|
|
||||||
/*-------------------- life & death of a driver --------------------------*/
|
/*-------------------- life & death of a driver --------------------------*/
|
||||||
pEVDriver CreateEVDriver(int argc, char *argv[]);
|
pEVDriver CreateEVDriver(int argc, char *argv[]);
|
||||||
|
1
event.c
1
event.c
@ -63,6 +63,7 @@
|
|||||||
"BATCHSTART",
|
"BATCHSTART",
|
||||||
"BATCHAREA",
|
"BATCHAREA",
|
||||||
"BATCHEND",
|
"BATCHEND",
|
||||||
|
"DRIVSTAT",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
11
event.h
11
event.h
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#line 85 "event.w"
|
#line 88 "event.w"
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
E V E N T
|
E V E N T
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
int Text2Event(char *pText);
|
int Text2Event(char *pText);
|
||||||
|
|
||||||
#line 98 "event.w"
|
#line 101 "event.w"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -41,19 +41,20 @@
|
|||||||
#define BATCHSTART 14
|
#define BATCHSTART 14
|
||||||
#define BATCHAREA 15
|
#define BATCHAREA 15
|
||||||
#define BATCHEND 16
|
#define BATCHEND 16
|
||||||
|
#define DRIVSTAT 17
|
||||||
|
|
||||||
#line 100 "event.w"
|
#line 103 "event.w"
|
||||||
|
|
||||||
|
|
||||||
/*--------------- Signals for the Signalfunction of each task ------------*/
|
/*--------------- Signals for the Signalfunction of each task ------------*/
|
||||||
|
|
||||||
#line 70 "event.w"
|
#line 73 "event.w"
|
||||||
|
|
||||||
#define SICSINT 300
|
#define SICSINT 300
|
||||||
#define SICSBROADCAST 301
|
#define SICSBROADCAST 301
|
||||||
#define TOKENGRAB 302
|
#define TOKENGRAB 302
|
||||||
#define TOKENRELEASE 303
|
#define TOKENRELEASE 303
|
||||||
|
|
||||||
#line 103 "event.w"
|
#line 106 "event.w"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,6 +52,7 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$
|
|||||||
\mbox{}\verb@#define BATCHSTART 14@\\
|
\mbox{}\verb@#define BATCHSTART 14@\\
|
||||||
\mbox{}\verb@#define BATCHAREA 15@\\
|
\mbox{}\verb@#define BATCHAREA 15@\\
|
||||||
\mbox{}\verb@#define BATCHEND 16@\\
|
\mbox{}\verb@#define BATCHEND 16@\\
|
||||||
|
\mbox{}\verb@#define DRIVSTAT 17@\\
|
||||||
\mbox{}\verb@@$\diamond$
|
\mbox{}\verb@@$\diamond$
|
||||||
\end{list}
|
\end{list}
|
||||||
\vspace{-1ex}
|
\vspace{-1ex}
|
||||||
@ -80,10 +81,12 @@ fiffractometer has been measured.
|
|||||||
\item[COUNTSTART] is an event which signals the start of a counting
|
\item[COUNTSTART] is an event which signals the start of a counting
|
||||||
operation.
|
operation.
|
||||||
\item[COUNTEND] is an event signalling the end of a counting operation.
|
\item[COUNTEND] is an event signalling the end of a counting operation.
|
||||||
\item[MOTEND] signals the end of a driving operation.
|
\item[MOTEND] signals the end of a motor driving operation.
|
||||||
\item[BATCHSTART] signals starting batch processing a new buffer
|
\item[BATCHSTART] signals starting batch processing a new buffer
|
||||||
\item[BATCHAREA] signals that a new area of the batch file is processing.
|
\item[BATCHAREA] signals that a new area of the batch file is processing.
|
||||||
\item[BATCHEND] signals the end of the batch buffers processing.
|
\item[BATCHEND] signals the end of the batch buffers processing.
|
||||||
|
\item[DRIVSTAT] signals a change in the status of a driving operation
|
||||||
|
(start, finished, fault)
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
Furthermore event contains system wide signal codes which are interpreted in
|
Furthermore event contains system wide signal codes which are interpreted in
|
||||||
|
5
event.w
5
event.w
@ -35,6 +35,7 @@ if the event code is not known, else the apropriate event code.
|
|||||||
#define BATCHSTART 14
|
#define BATCHSTART 14
|
||||||
#define BATCHAREA 15
|
#define BATCHAREA 15
|
||||||
#define BATCHEND 16
|
#define BATCHEND 16
|
||||||
|
#define DRIVSTAT 17
|
||||||
@}
|
@}
|
||||||
\begin{description}
|
\begin{description}
|
||||||
\item[VALUECHANGE] This is a variable changing its value. As event data a pointer to the
|
\item[VALUECHANGE] This is a variable changing its value. As event data a pointer to the
|
||||||
@ -55,10 +56,12 @@ fiffractometer has been measured.
|
|||||||
\item[COUNTSTART] is an event which signals the start of a counting
|
\item[COUNTSTART] is an event which signals the start of a counting
|
||||||
operation.
|
operation.
|
||||||
\item[COUNTEND] is an event signalling the end of a counting operation.
|
\item[COUNTEND] is an event signalling the end of a counting operation.
|
||||||
\item[MOTEND] signals the end of a driving operation.
|
\item[MOTEND] signals the end of a motor driving operation.
|
||||||
\item[BATCHSTART] signals starting batch processing a new buffer
|
\item[BATCHSTART] signals starting batch processing a new buffer
|
||||||
\item[BATCHAREA] signals that a new area of the batch file is processing.
|
\item[BATCHAREA] signals that a new area of the batch file is processing.
|
||||||
\item[BATCHEND] signals the end of the batch buffers processing.
|
\item[BATCHEND] signals the end of the batch buffers processing.
|
||||||
|
\item[DRIVSTAT] signals a change in the status of a driving operation
|
||||||
|
(start, finished, fault)
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
Furthermore event contains system wide signal codes which are interpreted in
|
Furthermore event contains system wide signal codes which are interpreted in
|
||||||
|
3
modriv.h
3
modriv.h
@ -64,8 +64,9 @@
|
|||||||
/* Simulation specific fields */
|
/* Simulation specific fields */
|
||||||
float fFailure; /* percent random failures*/
|
float fFailure; /* percent random failures*/
|
||||||
float fSpeed;
|
float fSpeed;
|
||||||
long iTime;
|
time_t iTime;
|
||||||
float fPos; /* position */
|
float fPos; /* position */
|
||||||
|
float fTarget; /* target position */
|
||||||
} SIMDriv;
|
} SIMDriv;
|
||||||
|
|
||||||
|
|
||||||
|
19
motor.c
19
motor.c
@ -76,6 +76,7 @@
|
|||||||
#define ECOUNT 11
|
#define ECOUNT 11
|
||||||
#define POSCOUNT 12
|
#define POSCOUNT 12
|
||||||
#define IGNOREFAULT 13
|
#define IGNOREFAULT 13
|
||||||
|
|
||||||
/*------------------------------------------------------------------------
|
/*------------------------------------------------------------------------
|
||||||
a tiny structure used in CallBack work
|
a tiny structure used in CallBack work
|
||||||
*/
|
*/
|
||||||
@ -119,6 +120,7 @@
|
|||||||
if(self->pDrivInt->iErrorCount < 0)
|
if(self->pDrivInt->iErrorCount < 0)
|
||||||
self->pDrivInt->iErrorCount = 0;
|
self->pDrivInt->iErrorCount = 0;
|
||||||
|
|
||||||
|
self->stopped = 1;
|
||||||
return self->pDriver->Halt((void *)self->pDriver);
|
return self->pDriver->Halt((void *)self->pDriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +210,7 @@ static int statusRunTo(pMotor self, SConnection *pCon)
|
|||||||
if(self->retryCount >= ObVal(self->ParArray,POSCOUNT))
|
if(self->retryCount >= ObVal(self->ParArray,POSCOUNT))
|
||||||
{
|
{
|
||||||
snprintf(pBueffel,255,"ERROR: aborting motor %s after %d retries",
|
snprintf(pBueffel,255,"ERROR: aborting motor %s after %d retries",
|
||||||
self->name, (int)ObVal(self->ParArray,POSCOUNT));
|
self->name, self->retryCount);
|
||||||
SCWrite(pCon,pBueffel,eError);
|
SCWrite(pCon,pBueffel,eError);
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
@ -230,10 +232,16 @@ static int checkPosition(pMotor self, SConnection *pCon)
|
|||||||
self->fPosition = fHard;
|
self->fPosition = fHard;
|
||||||
if(absf(fHard - self->fTarget) > ObVal(self->ParArray,PREC))
|
if(absf(fHard - self->fTarget) > ObVal(self->ParArray,PREC))
|
||||||
{
|
{
|
||||||
if(SCGetInterrupt(pCon) != eContinue)
|
if (SCGetInterrupt(pCon) != eContinue)
|
||||||
{
|
{
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
|
if(self->stopped)
|
||||||
|
{
|
||||||
|
snprintf(pBueffel,131,"WARNING: %s stopped", self->name);
|
||||||
|
SCWrite(pCon,pBueffel, eWarning);
|
||||||
|
return HWFault;
|
||||||
|
}
|
||||||
snprintf(pBueffel,131,"WARNING: %s off position by %f",
|
snprintf(pBueffel,131,"WARNING: %s off position by %f",
|
||||||
self->name, absf(fHard - self->fTarget));
|
self->name, absf(fHard - self->fTarget));
|
||||||
SCWrite(pCon,pBueffel, eWarning);
|
SCWrite(pCon,pBueffel, eWarning);
|
||||||
@ -248,6 +256,7 @@ static void finishDriving(pMotor self, SConnection *pCon)
|
|||||||
MotCallback sCall;
|
MotCallback sCall;
|
||||||
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
||||||
sCall.pName = self->name;
|
sCall.pName = self->name;
|
||||||
|
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
|
||||||
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
@ -494,7 +503,8 @@ static void handleMoveCallback(pMotor self, SConnection *pCon)
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/ pMotor MotorInit(char *drivername, char *name, MotorDriver *pDriv)
|
/*---------------------------------------------------------------------------*/
|
||||||
|
pMotor MotorInit(char *drivername, char *name, MotorDriver *pDriv)
|
||||||
{
|
{
|
||||||
pMotor pM = NULL;
|
pMotor pM = NULL;
|
||||||
|
|
||||||
@ -866,6 +876,7 @@ extern void KillPiPiezo(void *pData);
|
|||||||
/* Boundaries OK, send command */
|
/* Boundaries OK, send command */
|
||||||
self->posFaultCount = 0;
|
self->posFaultCount = 0;
|
||||||
self->retryCount = 0;
|
self->retryCount = 0;
|
||||||
|
self->stopped = 0;
|
||||||
self->fTarget = fHard;
|
self->fTarget = fHard;
|
||||||
iRet = self->pDriver->RunTo(self->pDriver,fHard);
|
iRet = self->pDriver->RunTo(self->pDriver,fHard);
|
||||||
if(iRet != OKOK)
|
if(iRet != OKOK)
|
||||||
@ -1392,7 +1403,7 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray);
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(pBueffel, " %s.%s = %f",self->name,pName->text,fValue);
|
sprintf(pBueffel, "%s.%s = %f",self->name,pName->text,fValue);
|
||||||
SCWrite(pCon,pBueffel,eValue);
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
DeleteTokenList(pList);
|
DeleteTokenList(pList);
|
||||||
return 1;
|
return 1;
|
||||||
|
1
motor.h
1
motor.h
@ -29,6 +29,7 @@
|
|||||||
motor callback */
|
motor callback */
|
||||||
int retryCount; /* for retries in status */
|
int retryCount; /* for retries in status */
|
||||||
int posFaultCount;
|
int posFaultCount;
|
||||||
|
int stopped;
|
||||||
} Motor;
|
} Motor;
|
||||||
typedef Motor *pMotor;
|
typedef Motor *pMotor;
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
2
ofac.c
2
ofac.c
@ -337,7 +337,7 @@
|
|||||||
RemoveCommand(pSics,"MakeLin2Ang");
|
RemoveCommand(pSics,"MakeLin2Ang");
|
||||||
RemoveCommand(pSics,"MakeSync");
|
RemoveCommand(pSics,"MakeSync");
|
||||||
RemoveCommand(pSics,"MakeHMControl");
|
RemoveCommand(pSics,"MakeHMControl");
|
||||||
RemoveCommand(pSics,"MakeRS232Controller");
|
/* RemoveCommand(pSics,"MakeRS232Controller"); */
|
||||||
RemoveCommand(pSics,"MakeMaxDetector");
|
RemoveCommand(pSics,"MakeMaxDetector");
|
||||||
RemoveCommand(pSics,"AntiColliderInstall");
|
RemoveCommand(pSics,"AntiColliderInstall");
|
||||||
RemoveCommand(pSics,"MakeGPIB");
|
RemoveCommand(pSics,"MakeGPIB");
|
||||||
|
Reference in New Issue
Block a user