- Fixes for FOCUS 2D
- Mapped fileeval to exe manager - Updates for TRICS file formats SKIPPED: psi/libpsi.a psi/sinqhmdriv.c psi/sinqhttp.c psi/tabledrive.c psi/tasscan.c psi/hardsup/asynsrv_utility.c psi/hardsup/sinqhm.c
This commit is contained in:
232
stdscan.c
232
stdscan.c
@ -64,8 +64,240 @@ static char *fixExtension(char *filename)
|
||||
}
|
||||
return fixExtension(pRes);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void WriteTemplate(FILE *fd, FILE *temp, char *filename, pScanData pScan,
|
||||
SConnection *pCon, SicsInterp *pSics)
|
||||
{
|
||||
char pBuffer[512], pError[512], *pPtr, *pName;
|
||||
CommandList *pCom = NULL;
|
||||
pSicsVariable pVar = NULL;
|
||||
pDummy pDum = NULL;
|
||||
pIDrivable pDriv = NULL;
|
||||
pMotor pMot = NULL;
|
||||
pVarEntry pScanVar = NULL;
|
||||
void *pVoid = NULL;
|
||||
float fVal;
|
||||
int iRet;
|
||||
|
||||
/* loop through description file and act along the way */
|
||||
while(fgets(pBuffer,511,temp) != NULL)
|
||||
{
|
||||
pPtr = strstr(pBuffer,"!!VAR(");
|
||||
if(pPtr) /* handle a Sics variable */
|
||||
{
|
||||
/* extract the name */
|
||||
pName = pPtr + 6; /* first char of name */
|
||||
*pPtr = '\0'; /* this is the starter of the line */
|
||||
pPtr = pName;
|
||||
while( (*pPtr != '\0') && (*pPtr != ')') )
|
||||
{
|
||||
pPtr++;
|
||||
}
|
||||
*pPtr = '\0';
|
||||
/* find the variable */
|
||||
pCom = FindCommand(pSics,pName);
|
||||
if(!pCom)
|
||||
{
|
||||
sprintf(pError,"ERROR: variable %s NOT found",pName);
|
||||
SCWrite(pCon,pError,eError);
|
||||
continue;
|
||||
}
|
||||
pVar = (pSicsVariable)pCom->pData;
|
||||
if(!pVar)
|
||||
{
|
||||
sprintf(pError,"ERROR: variable %s NOT found",pName);
|
||||
SCWrite(pCon,pError,eError);
|
||||
continue;
|
||||
}
|
||||
switch(pVar->eType)
|
||||
{
|
||||
case veFloat:
|
||||
sprintf(pError,"%f",pVar->fVal);
|
||||
break;
|
||||
case veInt:
|
||||
sprintf(pError,"%d",pVar->iVal);
|
||||
break;
|
||||
case veText:
|
||||
sprintf(pError,"%s",pVar->text);
|
||||
break;
|
||||
}
|
||||
/* finally write */
|
||||
fprintf(fd,"%s %s\n",pBuffer,pError);
|
||||
continue;
|
||||
}/* end variable */
|
||||
/*------- Drivable */
|
||||
pPtr = strstr(pBuffer,"!!DRIV(");
|
||||
if(pPtr)
|
||||
{
|
||||
/* extract the name */
|
||||
pName = pPtr + 7; /* first char of name */
|
||||
*pPtr = '\0'; /* this is the starter of the line */
|
||||
pPtr = pName;
|
||||
while( (*pPtr != '\0') && (*pPtr != ')') )
|
||||
{
|
||||
pPtr++;
|
||||
}
|
||||
*pPtr = '\0';
|
||||
/* find the variable */
|
||||
pCom = FindCommand(pSics,pName);
|
||||
if(!pCom)
|
||||
{
|
||||
sprintf(pError,"ERROR: variable %s NOT found",pName);
|
||||
SCWrite(pCon,pError,eError);
|
||||
continue;
|
||||
}
|
||||
pDum = (pDummy)pCom->pData;
|
||||
if(!pDum)
|
||||
{
|
||||
sprintf(pError,"ERROR: variable %s is NOT drivable",pName);
|
||||
SCWrite(pCon,pError,eError);
|
||||
continue;
|
||||
}
|
||||
pDriv = (pIDrivable)pDum->pDescriptor->GetInterface(pDum,DRIVEID);
|
||||
if(!pDriv)
|
||||
{
|
||||
sprintf(pError,"ERROR: variable %s is NOT drivable",pName);
|
||||
SCWrite(pCon,pError,eError);
|
||||
continue;
|
||||
}
|
||||
fVal = pDriv->GetValue(pDum,pCon);
|
||||
fprintf(fd,"%s %f\n",pBuffer,fVal);
|
||||
continue;
|
||||
} /* end drive */
|
||||
/*------- zero point */
|
||||
pPtr = strstr(pBuffer,"!!ZERO(");
|
||||
if(pPtr)
|
||||
{
|
||||
/* extract the name */
|
||||
pName = pPtr + 7; /* first char of name */
|
||||
*pPtr = '\0'; /* this is the starter of the line */
|
||||
pPtr = pName;
|
||||
while( (*pPtr != '\0') && (*pPtr != ')') )
|
||||
{
|
||||
pPtr++;
|
||||
}
|
||||
*pPtr = '\0';
|
||||
/* find the motor */
|
||||
pMot = FindMotor(pSics,pName);
|
||||
if(!pMot)
|
||||
{
|
||||
sprintf(pError,"ERROR: motor %s NOT found",pName);
|
||||
SCWrite(pCon,pError,eError);
|
||||
continue;
|
||||
}
|
||||
iRet = MotorGetPar(pMot,"softzero",&fVal);
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read zero point",eError);
|
||||
continue;
|
||||
}
|
||||
fprintf(fd,"%s %f\n",pBuffer,fVal);
|
||||
continue;
|
||||
} /* end zero point */
|
||||
/*---------- scripted info */
|
||||
pPtr = strstr(pBuffer,"!!SCRIPT(");
|
||||
if(pPtr)
|
||||
{
|
||||
/* extract the name */
|
||||
pName = pPtr + 9; /* first char of name */
|
||||
*pPtr = '\0'; /* this is the starter of the line */
|
||||
pPtr = pName;
|
||||
while( (*pPtr != '\0') && (*pPtr != ')') )
|
||||
{
|
||||
pPtr++;
|
||||
}
|
||||
*pPtr = '\0';
|
||||
if(Tcl_Eval(InterpGetTcl(pSics),pName) == TCL_OK)
|
||||
{
|
||||
fprintf(fd,"%s\n",Tcl_GetStringResult(InterpGetTcl(pSics)));
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to execute Tcl command",eError);
|
||||
strncpy(pBuffer, Tcl_GetStringResult(InterpGetTcl(pSics)), 511);
|
||||
SCWrite(pCon,pBuffer,eError);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* ------- date */
|
||||
pPtr = strstr(pBuffer,"!!DATE!!");
|
||||
if(pPtr)
|
||||
{
|
||||
*pPtr = '\0';
|
||||
SNXFormatTime(pError,511);
|
||||
fprintf(fd,"%s %s\n",pBuffer,pError);
|
||||
continue;
|
||||
}
|
||||
/*-------- filename */
|
||||
pPtr = strstr(pBuffer,"!!FILE!!");
|
||||
if(pPtr)
|
||||
{
|
||||
*pPtr = '\0';
|
||||
fprintf(fd,"%s %s\n",pBuffer,filename);
|
||||
continue;
|
||||
}
|
||||
/*------------ scanzero */
|
||||
pPtr = strstr(pBuffer,"!!SCANZERO!!");
|
||||
if(pPtr && pScan != NULL)
|
||||
{
|
||||
*pPtr = '\0';
|
||||
/* write zero point of first scan variable if motor */
|
||||
DynarGet(pScan->pScanVar,0,&pVoid);
|
||||
pScanVar = (pVarEntry)pVoid;
|
||||
if(pScanVar)
|
||||
{
|
||||
pMot = NULL;
|
||||
pMot = FindMotor(pSics,ScanVarName(pScanVar));
|
||||
if(pMot != NULL)
|
||||
{
|
||||
MotorGetPar(pMot,"softzero",&fVal);
|
||||
fprintf(fd,"%s zero = %8.3f\n",ScanVarName(pScanVar),
|
||||
fVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* --------- plain text */
|
||||
fprintf(fd,"%s",pBuffer);
|
||||
} /* end while */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int WriteHeader(pScanData self)
|
||||
{
|
||||
int i, iRet;
|
||||
FILE *fd;
|
||||
|
||||
assert(self->pSics);
|
||||
assert(self->pCon);
|
||||
|
||||
/* open data file */
|
||||
self->fd = fopen(self->pFile,"w");
|
||||
if(!self->fd)
|
||||
{
|
||||
SCWrite(self->pCon,"ERROR: cannot write data file",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* open header description file */
|
||||
fd = fopen(self->pHeaderFile,"r");
|
||||
if(!fd)
|
||||
{
|
||||
SCWrite(self->pCon,"ERROR: cannot open header description file",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WriteTemplate(self->fd,fd,self->pFile,
|
||||
self, self->pCon, self->pSics);
|
||||
|
||||
/* remember position for seeking to it for writing data */
|
||||
self->lPos = ftell(self->fd);
|
||||
|
||||
fclose(fd);
|
||||
fclose(self->fd);
|
||||
self->fd = NULL;
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int WriteHeaderOld(pScanData self)
|
||||
{
|
||||
int i, iRet;
|
||||
FILE *fd;
|
||||
|
Reference in New Issue
Block a user