- Removed old code
- Extended tasker to support task groups - Added task functions for motors and counters - Modifed devexec to use the new task functions - Modified TAS to treat the monochromator separatly - Coded a EIGER monochromator module to reflect even more new requirements - Added EPICS counters and motors - Modified multicounter to be better performing SKIPPED: psi/eigermono.c psi/make_gen psi/makefile_linux psi/psi.c psi/sinqhttp.c
This commit is contained in:
89
drive.c
89
drive.c
@ -160,7 +160,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
|
||||
|
||||
/* check if user is allowed to drive */
|
||||
if (!SCMatchRights(pCon, usUser)) {
|
||||
snprintf(pBueffel,511, "Insuficient Privilege to drive %s", name);
|
||||
snprintf(pBueffel,511, "ERROR: Insuficient Privilege to drive %s", name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -168,7 +168,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
|
||||
/* first try to find the thing to drive */
|
||||
pObject = FindCommand(pInter, name);
|
||||
if (!pObject) {
|
||||
snprintf(pBueffel,511, "Cannot find %s to drive ", name);
|
||||
snprintf(pBueffel,511, "ERROR: Cannot find %s to drive ", name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -179,7 +179,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
|
||||
pDum = (Dummy *) pObject->pData;
|
||||
pDes = pDum->pDescriptor;
|
||||
if (!pDes) {
|
||||
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
|
||||
snprintf(pBueffel,511, "ERROR: %s is NOT drivable!", pDes->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -189,14 +189,14 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
|
||||
*/
|
||||
pInt = pDes->GetInterface(pDum, DRIVEID);
|
||||
if (!pInt) {
|
||||
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
|
||||
snprintf(pBueffel,511, "ERROR: %s is NOT drivable!", pDes->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
if (pInt) {
|
||||
iRet = pInt->CheckLimits(pDum, fNew, pBueffel, 511);
|
||||
if (!iRet) {
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
SCPrintf(pCon, eError, "ERROR: %s", pBueffel);
|
||||
SCSetInterrupt(pCon, eAbortOperation);
|
||||
return 0;
|
||||
}
|
||||
@ -207,7 +207,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
snprintf(pBueffel,511, "%s is NOT drivable", pDes->name);
|
||||
snprintf(pBueffel,511, "ERROR: %s is NOT drivable", pDes->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -426,7 +426,72 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int MoveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
Tcl_Interp *tcl_interp;
|
||||
int iRet, i;
|
||||
double dTarget;
|
||||
float curPos;
|
||||
char pBueffel[512];
|
||||
Status eOld;
|
||||
long groupID, taskID;
|
||||
void *obj;
|
||||
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
tcl_interp = InterpGetTcl(pSics);
|
||||
/* check Status */
|
||||
eOld = GetStatus();
|
||||
|
||||
|
||||
/* check no of args */
|
||||
if (argc < 3) {
|
||||
snprintf(pBueffel,511, "Insufficient number of args. Usage %s name val",
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check authorisation */
|
||||
if (!SCMatchRights(pCon, usUser)) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: You are not authorized to use the mv command",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
groupID = GetTaskGroupID(pServ->pTasker);
|
||||
for (i = 1; i < argc; i += 2) {
|
||||
if (argv[i + 1] == NULL) {
|
||||
snprintf(pBueffel,511, "ERROR: no value found for driving %s", argv[i]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
SetStatus(eOld);
|
||||
return 0;
|
||||
}
|
||||
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
|
||||
if (iRet == TCL_ERROR) {
|
||||
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
|
||||
StopExe(GetExecutor(), "ALL");
|
||||
SetStatus(eOld);
|
||||
return 0;
|
||||
}
|
||||
obj = FindCommandData(pSics,argv[i],NULL);
|
||||
if(obj == NULL || GetDrivableInterface(obj) == NULL){
|
||||
SCPrintf(pCon,eError, "ERROR: %s not found, not started",argv[i]);
|
||||
break;
|
||||
}
|
||||
GetDrivablePosition(obj,pCon,&curPos);
|
||||
dTarget = curPos + dTarget;
|
||||
taskID = StartDriveTask(obj, pCon, argv[i], (float)dTarget);
|
||||
AddTaskToGroup(pServ->pTasker,taskID,groupID);
|
||||
}
|
||||
while(isTaskGroupRunning(pServ->pTasker,groupID)){
|
||||
TaskYield(pServ->pTasker);
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int MakeDrive(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
@ -457,5 +522,17 @@ int MakeDrive(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc > 3) {
|
||||
iRet = AddCommand(pSics, argv[2], MoveWrapper, NULL, NULL);
|
||||
} else {
|
||||
iRet = AddCommand(pSics, "mv", MoveWrapper, NULL, NULL);
|
||||
}
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel, "ERROR: duplicate command mv not created");
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user