- Many fixes to accomodate a nitty picky TRICS wishlist

- Added a log facility to scan which includes a variable which is logged but
  not driven during a scan.
- Fixed normal beam operation
This commit is contained in:
koennecke
2006-01-27 11:33:06 +00:00
parent 45fd50265f
commit b737b4d936
17 changed files with 367 additions and 182 deletions

View File

@ -65,6 +65,55 @@ pVarEntry MakeScanVar(SicsInterp *pSics, SConnection *pCon, char
return pVar;
}
/*----------------------------------------------------------------------*/
pVarEntry MakeLogVar(SicsInterp *pSics, SConnection *pCon, char *name){
CommandList *pCom = NULL;
pIDrivable pDriv = NULL;
pDummy pData = NULL;
pVarEntry pVar = NULL;
char pBueffel[512];
/*
allocate space
*/
pVar = (pVarEntry)malloc(sizeof(VarEntry));
if(pVar == NULL){
SCWrite(pCon,"ERROR: out of memory allocating scan variable",eError);
return NULL;
}
memset(pVar,0,sizeof(VarEntry));
/* find the thing */
pCom = FindCommand(pSics,name);
if(!pCom){
snprintf(pBueffel,511,"ERROR: Cannot find variable %s to log",name);
SCWrite(pCon,pBueffel,eError);
return NULL;
}
pData = (pDummy)pCom->pData;
if(!pData){
snprintf(pBueffel,511,"ERROR: Cannot find data for variable %s",name);
SCWrite(pCon,pBueffel,eError);
return NULL;
}
pDriv = pData->pDescriptor->GetInterface(pData,DRIVEID);
if(!pDriv){
snprintf(pBueffel,511,
"ERROR: variable %s is NOT driveable and cannot be logged",name);
SCWrite(pCon,pBueffel,eError);
return NULL;
}
/* got everything, fill in the VarEntry structure */
strcpy(pVar->Name,name);
pVar->pInter = pDriv;
pVar->pObject = pData;
pVar->logVar = 1;
pVar->dataList = LLDcreate(sizeof(float));
return pVar;
}
/*------------------------------------------------------------------*/
void InitScanVar(pVarEntry pVar){
LLDdelete(pVar->dataList);
@ -105,6 +154,13 @@ int StartScanVar(pVarEntry pVar, SConnection *pCon, int i){
char pBueffel[512];
int status;
/**
* logged variables are not started
*/
if(pVar->logVar == 1){
return 1;
}
pDum = (pDummy)pVar->pObject;
fVal = pVar->fStart + i * pVar->fStep;
status = StartDevice(pServ->pExecutor,
@ -122,6 +178,32 @@ int StartScanVar(pVarEntry pVar, SConnection *pCon, int i){
return 1;
}
/*-------------------------------------------------------------------------*/
int CheckScanVar(pVarEntry pVar, SConnection *pCon, int np){
int status;
char pError[132], pBueffel[512];
if(pVar->logVar == 1){
return 1;
}
status = pVar->pInter->CheckLimits(pVar->pObject,
pVar->fStart,pError,131);
if(status != 1){
snprintf(pBueffel,511,"ERROR: %s, scan aborted",pError);
SCWrite(pCon,pBueffel,eError);
return 0;
}
status = pVar->pInter->CheckLimits(pVar->pObject,
pVar->fStart + np * pVar->fStep,
pError,131);
if(status != 1){
snprintf(pBueffel,511,"ERROR: %s, scan aborted",pError);
SCWrite(pCon,pBueffel,eError);
return 0;
}
return 1;
}
/*-------------------------------------------------------------------------*/
void AppendScanVar(pVarEntry pVar, float pos){
float fVal = pos;
LLDnodeAppendFrom(pVar->dataList,&fVal);
@ -151,4 +233,8 @@ void CopyScanVar(pVarEntry pVar, float *fData, int np){
status = LLDnodePtr2Next(pVar->dataList);
}
}
/*-------------------------------------------------------------------------*/
int isLogVar(pVarEntry pVar){
return pVar->logVar;
}