- 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

@ -105,6 +105,7 @@
long lTask;
pTaskMan pTask;
int iLock;
pICallBack pCall;
} ExeList;
static pExeList pExecutor = NULL;
@ -139,6 +140,7 @@
pRes->pTask = pTask;
pRes->lTask = -1;
pRes->iLock = 0;
pRes->pCall = CreateCallBackInterface();
return pRes;
}
/*-------------------------------------------------------------------------*/
@ -153,9 +155,21 @@
DeleteDescriptor(self->pDes);
ClearExecutor(self);
LLDdelete(self->iList);
if(self->pCall)
DeleteCallBackInterface(self->pCall);
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,
void *pData, SConnection *pCon, float fNew)
@ -220,6 +234,7 @@
if(iRet == OKOK)
{
LLDnodeAppendFrom(self->iList,&pNew);
ExeInterest(self, pNew, "started");
self->iRun = 1;
self->iStatus = DEVDONE;
/* if no task: start it */
@ -388,6 +403,7 @@
{
pDrivInt->iErrorCount = 0;
}
ExeInterest(self, pDev, "finished");
DeleteDevEntry(pDev);
LLDnodeDelete(self->iList);
iRet = LLDnodePtr2Prev(self->iList);
@ -399,6 +415,7 @@
self->iStatus = DEVDONE;
break;
case HWFault: /* real HW error: burning, no net etc.. */
ExeInterest(self, pDev, "finished with problem");
DeleteDevEntry(pDev);
LLDnodeDelete(self->iList);
self->iStatus = DEVERROR;
@ -446,6 +463,7 @@
self->iStatus = DEVBUSY;
break;
case HWPosFault: /* cannot get somewhere... */
ExeInterest(self, pDev, "finished with problem");
DeleteDevEntry(pDev);
LLDnodeDelete(self->iList);
self->iStatus = DEVERROR;
@ -561,6 +579,9 @@
return 1;
}
/* first the ALL case */
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
@ -575,9 +596,6 @@
self->iStop = 1;
}
/* first the ALL case */
if(strcmp(name,"all") == 0)
{
iRet = LLDnodePtr2First(self->iList);
while(iRet != 0)
{
@ -797,12 +815,48 @@
}
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 argc, char *argv[])
{
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:
Success
@ -927,12 +981,17 @@
iInterrupt = SCGetInterrupt(self->pOwner);
if(iInterrupt != eContinue)
{
SCWrite(self->pOwner,pBueffel, eError);
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);
snprintf(pBueffel,131,"ERROR: interrupt %s triggered",
pInterrupt);
SCWrite(self->pOwner,pBueffel, eError);
*/
StopExe(self,"all");
}
#ifdef DEBUG

View File

@ -83,6 +83,7 @@
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,8 +179,9 @@
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);
@ -254,13 +256,12 @@
self->eMode = EVMonitor;
return HWIdle;
}
if(fDelta <= ObVal(self->pParam, TOLERANCE)) /* done */
{
if (iCount < 3)
{
iCount++;
return HWBusy;
tol = ObVal(self->pParam, TOLERANCE);
if (self->lastt > 0) { /* increase tol for hysteresis */
tol=tol*1.1001;
}
if(fDelta <= tol) /* inside tolerance */
{
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,6 +553,7 @@ 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,10 +745,8 @@ static void ErrReport(pEVControl self)
pDriv->GetValues=StdGetValues;
}
iRet = pDriv->Init(pDriv);
if(iRet >= 0)
{
*iErr = iRet;
}
/* new var log for logging values */
pRes->iLog = 1;
@ -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]);
pCom = FindCommand(pSics,argv[2]);
if(pCom)
{
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;
}
pNew = InstallCommonControllers(pSics,pCon,argc,argv);
if(pNew == NULL)
}
pCom = FindCommand(pSics,argv[2]);
if(pCom)
{
sprintf(pBueffel, "ERROR: command %s already exists", argv[2]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
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);
/* 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);

View File

@ -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
@ -14,7 +14,7 @@
#define SICSEVCONTROL
#include "varlog.h"
#line 144 "evcontroller.w"
#line 146 "evcontroller.w"
/*--------------------------- live & death --------------------------------*/
typedef struct __EVControl *pEVControl;
@ -22,7 +22,9 @@
pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);
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 ---------------------------------*/
int EVCDrive(pEVControl self,SConnection *pCon, float fNew);
int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);
@ -44,6 +46,6 @@
#line 235 "evcontroller.w"
#line 239 "evcontroller.w"
#endif

View File

@ -1,5 +1,5 @@
#line 239 "evcontroller.w"
#line 243 "evcontroller.w"
/*-------------------------------------------------------------------------
Environment controller datastructure
@ -41,9 +41,11 @@
int iWarned;
int iTcl;
int iStop;
SCStore conn;
char *creationArgs;
void *pPrivate;
void (*KillPrivate)(void *pData);
} EVControl;
#line 257 "evcontroller.w"
#line 261 "evcontroller.w"

View File

@ -52,6 +52,8 @@ $\langle$evdata {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ int iWarned;@\\
\mbox{}\verb@ int iTcl;@\\
\mbox{}\verb@ int iStop;@\\
\mbox{}\verb@ SCStore conn;@\\
\mbox{}\verb@ char *creationArgs;@\\
\mbox{}\verb@ void *pPrivate;@\\
\mbox{}\verb@ void (*KillPrivate)(void *pData);@\\
\mbox{}\verb@ } EVControl;@\\
@ -161,7 +163,7 @@ a drivers specific datastructure properly.
\end{description}
\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
data structure as first parameter.
@ -177,7 +179,9 @@ $\langle$dvfunc {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@@\\
\mbox{}\verb@ pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);@\\
\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@ int EVCDrive(pEVControl self,SConnection *pCon, float fNew);@\\
\mbox{}\verb@ int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);@\\

View File

@ -47,6 +47,8 @@ used by EVControl:
int iWarned;
int iTcl;
int iStop;
SCStore conn;
char *creationArgs;
void *pPrivate;
void (*KillPrivate)(void *pData);
} EVControl;
@ -137,7 +139,7 @@ a drivers specific datastructure properly.
\end{description}
\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
data structure as first parameter.
@ -148,7 +150,9 @@ data structure as first parameter.
pEVControl CreateEVController(pEVDriver pDriv, char *pName, int *iErr);
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 ---------------------------------*/
int EVCDrive(pEVControl self,SConnection *pCon, float fNew);
int EVCGetPos(pEVControl self, SConnection *pCon,float *fVal);

View File

@ -1,5 +1,5 @@
#line 260 "evcontroller.w"
#line 264 "evcontroller.w"
/*-------------------------------------------------------------------------
Environment device driver datastructure
@ -12,7 +12,7 @@
#define DEVREDO 2
#line 85 "evcontroller.w"
#line 87 "evcontroller.w"
typedef struct __EVDriver {
int (*SetValue)(pEVDriver self, float fNew);
@ -30,7 +30,7 @@
void (*KillPrivate)(void *pData);
} EVDriver;
#line 271 "evcontroller.w"
#line 275 "evcontroller.w"
/*-------------------- life & death of a driver --------------------------*/
pEVDriver CreateEVDriver(int argc, char *argv[]);

View File

@ -63,6 +63,7 @@
"BATCHSTART",
"BATCHAREA",
"BATCHEND",
"DRIVSTAT",
NULL
};

11
event.h
View File

@ -1,5 +1,5 @@
#line 85 "event.w"
#line 88 "event.w"
/*----------------------------------------------------------------------------
E V E N T
@ -18,7 +18,7 @@
int Text2Event(char *pText);
#line 98 "event.w"
#line 101 "event.w"
@ -41,19 +41,20 @@
#define BATCHSTART 14
#define BATCHAREA 15
#define BATCHEND 16
#define DRIVSTAT 17
#line 100 "event.w"
#line 103 "event.w"
/*--------------- Signals for the Signalfunction of each task ------------*/
#line 70 "event.w"
#line 73 "event.w"
#define SICSINT 300
#define SICSBROADCAST 301
#define TOKENGRAB 302
#define TOKENRELEASE 303
#line 103 "event.w"
#line 106 "event.w"
#endif

View File

@ -52,6 +52,7 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@#define BATCHSTART 14@\\
\mbox{}\verb@#define BATCHAREA 15@\\
\mbox{}\verb@#define BATCHEND 16@\\
\mbox{}\verb@#define DRIVSTAT 17@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-1ex}
@ -80,10 +81,12 @@ fiffractometer has been measured.
\item[COUNTSTART] is an event which signals the start 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[BATCHAREA] signals that a new area of the batch file is 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}
Furthermore event contains system wide signal codes which are interpreted in

View File

@ -35,6 +35,7 @@ if the event code is not known, else the apropriate event code.
#define BATCHSTART 14
#define BATCHAREA 15
#define BATCHEND 16
#define DRIVSTAT 17
@}
\begin{description}
\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
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[BATCHAREA] signals that a new area of the batch file is 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}
Furthermore event contains system wide signal codes which are interpreted in

View File

@ -64,8 +64,9 @@
/* Simulation specific fields */
float fFailure; /* percent random failures*/
float fSpeed;
long iTime;
time_t iTime;
float fPos; /* position */
float fTarget; /* target position */
} SIMDriv;

15
motor.c
View File

@ -76,6 +76,7 @@
#define ECOUNT 11
#define POSCOUNT 12
#define IGNOREFAULT 13
/*------------------------------------------------------------------------
a tiny structure used in CallBack work
*/
@ -119,6 +120,7 @@
if(self->pDrivInt->iErrorCount < 0)
self->pDrivInt->iErrorCount = 0;
self->stopped = 1;
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))
{
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);
return HWFault;
}
@ -234,6 +236,12 @@ static int checkPosition(pMotor self, SConnection *pCon)
{
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",
self->name, absf(fHard - self->fTarget));
SCWrite(pCon,pBueffel, eWarning);
@ -248,6 +256,7 @@ static void finishDriving(pMotor self, SConnection *pCon)
MotCallback sCall;
MotorGetSoftPosition(self,pCon,&sCall.fVal);
sCall.pName = self->name;
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
InvokeCallBack(self->pCall, MOTEND, &sCall);
}
/*--------------------------------------------------------------------*/
@ -494,7 +503,8 @@ static void handleMoveCallback(pMotor self, SConnection *pCon)
}
return status;
}
/*---------------------------------------------------------------------------*/ pMotor MotorInit(char *drivername, char *name, MotorDriver *pDriv)
/*---------------------------------------------------------------------------*/
pMotor MotorInit(char *drivername, char *name, MotorDriver *pDriv)
{
pMotor pM = NULL;
@ -866,6 +876,7 @@ extern void KillPiPiezo(void *pData);
/* Boundaries OK, send command */
self->posFaultCount = 0;
self->retryCount = 0;
self->stopped = 0;
self->fTarget = fHard;
iRet = self->pDriver->RunTo(self->pDriver,fHard);
if(iRet != OKOK)

View File

@ -29,6 +29,7 @@
motor callback */
int retryCount; /* for retries in status */
int posFaultCount;
int stopped;
} Motor;
typedef Motor *pMotor;
/*-------------------------------------------------------------------------*/

2
ofac.c
View File

@ -337,7 +337,7 @@
RemoveCommand(pSics,"MakeLin2Ang");
RemoveCommand(pSics,"MakeSync");
RemoveCommand(pSics,"MakeHMControl");
RemoveCommand(pSics,"MakeRS232Controller");
/* RemoveCommand(pSics,"MakeRS232Controller"); */
RemoveCommand(pSics,"MakeMaxDetector");
RemoveCommand(pSics,"AntiColliderInstall");
RemoveCommand(pSics,"MakeGPIB");