- inserted command statistic
- add runscript parameter to environment object - added Arg2Tcl0 function
This commit is contained in:
@ -71,13 +71,29 @@
|
||||
static long EVIDrive(void *pData, SConnection *pCon, float fVal)
|
||||
{
|
||||
pEVControl self = NULL;
|
||||
int iRet, iCode, i, iFix;
|
||||
int iRet, iCode, i, iFix, savedStatus;
|
||||
char pError[132], pBueffel[256];
|
||||
|
||||
Tcl_Interp *pTcl = NULL;
|
||||
|
||||
self = (pEVControl)pData;
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
if (self->runScript != NULL) {
|
||||
savedStatus = GetStatus();
|
||||
SetStatus(eBatch);
|
||||
pTcl = InterpGetTcl(pServ->pSics);
|
||||
snprintf(pBueffel, sizeof(pBueffel), "%s %f", self->runScript, fVal);
|
||||
iRet = Tcl_Eval(pTcl,pBueffel);
|
||||
SetStatus(savedStatus);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
SCPrintf(pCon, eError,
|
||||
"ERROR: %s while processing runscript for %s",
|
||||
pTcl->result,self->pName);
|
||||
}
|
||||
}
|
||||
|
||||
self->fTarget = fVal;
|
||||
self->eMode = EVDrive;
|
||||
self->iStop = 0;
|
||||
@ -848,6 +864,10 @@ static void ErrReport(pEVControl self)
|
||||
{
|
||||
free(self->creationArgs);
|
||||
}
|
||||
if (self->runScript != NULL)
|
||||
{
|
||||
free(self->runScript);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -855,7 +875,7 @@ static void ErrReport(pEVControl self)
|
||||
{
|
||||
char pBueffel[256], pError[132];
|
||||
int iRet;
|
||||
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
@ -1025,7 +1045,14 @@ static void ErrReport(pEVControl self)
|
||||
snprintf(pBueffel,255,"%s.errorScript = UNDEFINED", self->pName);
|
||||
}
|
||||
SCWrite(pCon,pBueffel, eValue);
|
||||
|
||||
if(self->runScript != NULL)
|
||||
{
|
||||
SCPrintf(pCon, eValue, "%s.runScript = %s", self->pName, self->runScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCPrintf(pCon, eValue, "%s.runScript = none", self->pName);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -1161,10 +1188,10 @@ static void ErrReport(pEVControl self)
|
||||
}
|
||||
else /* parameter request */
|
||||
{
|
||||
strtolower(argv[1]);
|
||||
/*
|
||||
catch case of errorScript
|
||||
*/
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"errorscript") == 0)
|
||||
{
|
||||
if(self->errorScript != NULL)
|
||||
@ -1180,6 +1207,22 @@ static void ErrReport(pEVControl self)
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
catch case of runScript
|
||||
*/
|
||||
if(strcmp(argv[1],"runscript") == 0)
|
||||
{
|
||||
if(self->runScript != NULL)
|
||||
{
|
||||
SCPrintf(pCon, eValue,"%s.runScript = %s",self->pName,
|
||||
self->runScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCPrintf(pCon, eValue,"%s.runScript = none",self->pName);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
catch case for drivername
|
||||
*/
|
||||
@ -1208,10 +1251,10 @@ static void ErrReport(pEVControl self)
|
||||
}
|
||||
else /* try to set parameter */
|
||||
{
|
||||
strtolower(argv[1]);
|
||||
/*
|
||||
first catch case of errorScript
|
||||
*/
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"errorscript") == 0)
|
||||
{
|
||||
if(self->errorScript != NULL)
|
||||
@ -1223,6 +1266,24 @@ static void ErrReport(pEVControl self)
|
||||
SCparChange(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
catch case of runScript
|
||||
*/
|
||||
if(strcmp(argv[1],"runscript") == 0)
|
||||
{
|
||||
if(self->runScript != NULL)
|
||||
{
|
||||
free(self->runScript);
|
||||
}
|
||||
if (strcasecmp(argv[2],"none") == 0) {
|
||||
self->runScript = NULL;
|
||||
} else {
|
||||
self->runScript = Arg2Tcl(argc-2,&argv[2],NULL,0);
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
SCparChange(pCon);
|
||||
return 1;
|
||||
}
|
||||
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
@ -1263,6 +1324,9 @@ static int EVSaveStatus(void *pData, char *name, FILE *fil)
|
||||
if(evc->errorScript != NULL) {
|
||||
fprintf(fil, " %s errorScript %s\n", evc->pName, evc->errorScript);
|
||||
}
|
||||
if(evc->runScript != NULL) {
|
||||
fprintf(fil, " %s runScript %s\n", evc->pName, evc->runScript);
|
||||
}
|
||||
}
|
||||
fprintf(fil, "}\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user