- Fixed a bug in conman.c which could cause a core dump when terminating
a connection during an active run. - Added an additional output mode for the connection in order to support the batch run editor. - Made clientput send everything with eWarning mode in order to support the batch run editor. - Added a better NetReadTillTerm - Fixed a problem in synchronize.c - Fixed an issue with reading empty line on normal connection sockets. - Added a psi scan mode to mesure.c for TRICS - Made motor print warnings when trying to reposition. - Fixed abug in hkl.c which cause wrong signs. SKIPPED: psi/el734driv.c psi/el734hp.c psi/el737driv.c psi/el737hpdriv.c psi/nextrics.c psi/nxamor.c psi/psi.c psi/slsmagnet.c psi/swmotor2.c psi/tasscan.c psi/tasutil.c
This commit is contained in:
191
sicvar.c
191
sicvar.c
@@ -39,6 +39,7 @@
|
||||
#include "fortify.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <tcl.h>
|
||||
#include "sics.h"
|
||||
#include <string.h>
|
||||
#include "splitter.h"
|
||||
@@ -411,11 +412,41 @@
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int VarSetFromText(pSicsVariable self, SConnection *pCon, char *text)
|
||||
{
|
||||
int status;
|
||||
double dVal;
|
||||
char pBueffel[132];
|
||||
|
||||
if(!SCMatchRights(pCon,self->iAccessCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(self->eType == veText)
|
||||
{
|
||||
return VarSetText(self,text,SCGetRights(pCon));
|
||||
}
|
||||
status = Tcl_GetDouble(InterpGetTcl(pServ->pSics), text,&dVal);
|
||||
if(status != TCL_OK)
|
||||
{
|
||||
snprintf(pBueffel,131,"ERROR: failed to convert %s to number",
|
||||
text);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(self->eType == veInt)
|
||||
{
|
||||
return VarSetInt(self,(int)dVal,SCGetRights(pCon));
|
||||
}
|
||||
else if(self->eType == veFloat)
|
||||
{
|
||||
return VarSetFloat(self,(float)dVal,SCGetRights(pCon));
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
Variables understands some commands:
|
||||
setrights : for setting uer rights
|
||||
setrights : for setting user rights
|
||||
lock : for locking the variable
|
||||
interest : for notifictaion on value change
|
||||
uninterest : delete notification
|
||||
@@ -499,7 +530,9 @@
|
||||
/* is control grabbed ? */
|
||||
if(SCGetGrab(pCon) != 0)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: somebody else has grabbed control, Request REJECTED",eError);
|
||||
SCWrite(pCon,
|
||||
"ERROR: somebody else has grabbed control, Request REJECTED",
|
||||
eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
@@ -546,94 +579,74 @@
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/* now, only a new value is still possible */
|
||||
eStat = GetStatus();
|
||||
if( (eStat != eEager) && (eStat != eBatch) )
|
||||
else if(strcmp(pCurrent->text,"force") == 0)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"You cannot set variables while a scan is running",eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
|
||||
/*
|
||||
Undocumented feauture: force a set even while driving etc.
|
||||
Internal privilege required to do this.
|
||||
*/
|
||||
if(!SCMatchRights(pCon,usInternal))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pCurrent = pCurrent->pNext;
|
||||
if(!pCurrent)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: new value missing for force",eError);
|
||||
return 0;
|
||||
}
|
||||
Arg2Text(argc-2,&argv[2],pBueffel,255);
|
||||
iRet = VarSetFromText(pVar,pCon,pBueffel);
|
||||
if(iRet == 1)
|
||||
{
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
SCparChange(pCon);
|
||||
DeleteTokenList(pList);
|
||||
return iRet;
|
||||
}
|
||||
iRet = 0;
|
||||
if(pCurrent)
|
||||
else
|
||||
{
|
||||
/* is it locked ? */
|
||||
if(pVar->iLock)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: variable %s is configured locked!",
|
||||
argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
/* is control grabbed ? */
|
||||
if(SCGetGrab(pCon) != 0)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: somebody else has grabbed control, Request REJECTED",eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
/* do not care for typechecks if text */
|
||||
if(eTyp == veText)
|
||||
{
|
||||
Arg2Text(argc-1,&argv[1],pBueffel,255);
|
||||
iRet = VarSetText(pVar,pBueffel,SCGetRights(pCon));
|
||||
}
|
||||
else if(eTyp == veInt)
|
||||
{
|
||||
if(pCurrent->Type == eFloat)
|
||||
{
|
||||
iVal = (int)pCurrent->fVal;
|
||||
}
|
||||
else if(pCurrent->Type == eInt)
|
||||
{
|
||||
iVal = pCurrent->iVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(pBueffel,"Wrong Type: cannot assign %s to %s",
|
||||
pCurrent->text, argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
iRet = VarSetInt(pVar,iVal,SCGetRights(pCon));
|
||||
}
|
||||
else if(eTyp == veFloat)
|
||||
{
|
||||
if(pCurrent->Type == eFloat)
|
||||
{
|
||||
fVal = pCurrent->fVal;
|
||||
}
|
||||
else if(pCurrent->Type == eInt)
|
||||
{
|
||||
fVal = (float)pCurrent->iVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(pBueffel,"Wrong Type: cannot assign %s to %s",
|
||||
pCurrent->text, argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
iRet = VarSetFloat(pVar,fVal,SCGetRights(pCon));
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"Insufficient Privilege to change %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
SCparChange(pCon);
|
||||
DeleteTokenList(pList);
|
||||
return 1;
|
||||
}
|
||||
/* now, only a new value is still possible */
|
||||
eStat = GetStatus();
|
||||
if( (eStat != eEager) && (eStat != eBatch) )
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"You cannot set variables while a scan is running",eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
|
||||
}
|
||||
iRet = 0;
|
||||
if(pCurrent)
|
||||
{
|
||||
/* is it locked ? */
|
||||
if(pVar->iLock)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: variable %s is configured locked!",
|
||||
argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
/* is control grabbed ? */
|
||||
if(SCGetGrab(pCon) != 0)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: somebody else has grabbed control, Request REJECTED",eError);
|
||||
DeleteTokenList(pList);
|
||||
return 0;
|
||||
}
|
||||
Arg2Text(argc-1,&argv[1],pBueffel,255);
|
||||
iRet = VarSetFromText(pVar,pCon,pBueffel);
|
||||
if(iRet == 1)
|
||||
{
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
SCparChange(pCon);
|
||||
DeleteTokenList(pList);
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we are here, no valid command was found */
|
||||
SCWrite(pCon,
|
||||
|
||||
Reference in New Issue
Block a user