- Scriptcontext debugged to be working

- Added a drivable adapter to scriptcontext nodes
- Added subsampling to simulated histograms (and as a general option) in
  order to support Gumtree testing.
This commit is contained in:
koennecke
2008-06-09 08:57:53 +00:00
parent 3cb901b437
commit 0915491925
33 changed files with 1938 additions and 247 deletions

View File

@ -13,7 +13,7 @@
#include <splitter.h>
#include "polldriv.h"
#include "splitter.h"
#include "macro.h"
#include "sicshipadaba.h"
/*================ actual driver implementation =========================*/
static int timeDue(struct __POLLDRIV *self, time_t now, SConnection *pCon){
@ -73,6 +73,58 @@ static pPollDriv makeHdbDriver(SConnection *pCon, char *objectIdentifier,
pNew->pollIntervall = 10;
}
return pNew;
}
/*==================== script poll driver ========================*/
static int pollScript(struct __POLLDRIV *self, SConnection *pCon){
int status;
Tcl_Interp *pTcl = InterpGetTcl(pServ->pSics);
self->nextPoll = time(NULL) + self->pollIntervall;
MacroPush(pCon);
status = Tcl_Eval(pTcl,(char *)self->objPointer);
MacroPop();
if(status == 0){
return 1;
} else {
return 0;
}
}
/*-----------------------------------------------------------------------*/
static void killScriptObj(void *data){
if(data != NULL){
free(data);
}
}
/*-----------------------------------------------------------------------*/
static pPollDriv makeScriptDriver(SConnection *pCon, char *objectIdentifier,
int argc, char *argv[]){
pPollDriv pNew = NULL;
char scriptBuffer[512];
if(argc < 2){
SCWrite(pCon,
"ERROR: need intervall and script parameter for script polling driver", eError);
return NULL;
}
pNew = malloc(sizeof(PollDriv));
if(pNew == NULL){
return NULL;
}
memset(pNew,0,sizeof(PollDriv));
pNew->pollIntervall = atoi(argv[0]);
memset(scriptBuffer,0,512);
Arg2Text(argc-1, &argv[1],scriptBuffer,511);
pNew->objectIdentifier = strdup(objectIdentifier);
pNew->objPointer = strdup(scriptBuffer);
pNew->isDue = timeDue;
pNew->poll = pollScript;
pNew->killObjPointer = killScriptObj;
return pNew;
}
/*================ external interface ====================================*/
@ -81,7 +133,9 @@ pPollDriv makePollDriver(SConnection *pCon, char *driver,
strtolower(driver);
if(strcmp(driver,"hdb") == 0) {
return makeHdbDriver(pCon,objectIdentifier, argc, argv);
return makeHdbDriver(pCon,objectIdentifier, argc, argv);
} else if(strcmp(driver,"script") == 0){
return makeScriptDriver(pCon,objectIdentifier, argc, argv);
} else {
SCWrite(pCon,"ERROR: polling driver type unknown",eError);
return NULL;
@ -92,5 +146,8 @@ void deletePollDriv(pPollDriv self){
if(self->objectIdentifier != NULL){
free(self->objectIdentifier);
}
if(self->objPointer != NULL && self->killObjPointer != NULL){
self->killObjPointer(self->objPointer);
}
free(self);
}