- Adapted amor status stuff to work with the new http based HM
This commit is contained in:
46
sinqhttp.c
46
sinqhttp.c
@@ -33,6 +33,7 @@ static char statusdaq[] = {"/admin/textstatus.egi"};
|
||||
static char gethm[] = {"/admin/readhmdata.egi"};
|
||||
static char configure[] = {"/admin/configure.egi"};
|
||||
static char preset[] = {"/admin/presethm.egi"};
|
||||
static char subsample[] = {"/admin/processhmdata.egi"};
|
||||
/*====================================================================
|
||||
error codes
|
||||
======================================================================*/
|
||||
@@ -44,6 +45,7 @@ static char preset[] = {"/admin/presethm.egi"};
|
||||
#define SERVERERROR -706
|
||||
#define BADSTATUS -707
|
||||
#define BADAUTH -708
|
||||
#define HMNOMEMORY -709
|
||||
/*=====================================================================
|
||||
our driver private data structure
|
||||
======================================================================*/
|
||||
@@ -125,6 +127,7 @@ static int sinqHttpGet(pSinqHttp self, char *request){
|
||||
if(httpStatus != ghttp_done){
|
||||
ghttp_close(self->syncRequest);
|
||||
sinqHttpGetPrepare(self,request);
|
||||
ghttp_prepare(self->syncRequest);
|
||||
httpStatus = ghttp_process(self->syncRequest);
|
||||
}
|
||||
if(httpStatus != ghttp_done){
|
||||
@@ -441,9 +444,9 @@ static int SinqHttpFixIt(pHistDriver self, int code){
|
||||
if(code == SERVERERROR){
|
||||
pPriv->failCount++;
|
||||
if(pPriv->failCount > 2){
|
||||
return COTERM;
|
||||
return COTERM;
|
||||
} else {
|
||||
return COREDO;
|
||||
return COREDO;
|
||||
}
|
||||
}
|
||||
return COTERM;
|
||||
@@ -487,6 +490,42 @@ static int SinqHttpGetHistogram(pHistDriver self, SConnection *pCon,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
static HistInt *SinqHttpSubSample(pHistDriver self, SConnection *pCon,
|
||||
int bank, char *hmcommand){
|
||||
char command[1024];
|
||||
HistInt *hmdata = NULL;
|
||||
HistInt *resultdata = NULL;
|
||||
pSinqHttp pPriv = NULL;
|
||||
int status, len, i;
|
||||
|
||||
pPriv = (pSinqHttp)self->pPriv;
|
||||
assert(pPriv != NULL);
|
||||
|
||||
snprintf(command,1023,"%s?bank=%d&command=%s",subsample,bank,
|
||||
hmcommand);
|
||||
|
||||
status = sinqHttpGet(pPriv,command);
|
||||
if(status != 1){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = ghttp_get_body_len(pPriv->syncRequest);
|
||||
resultdata = malloc(len+4);
|
||||
if(resultdata == NULL){
|
||||
strncpy(pPriv->hmError,
|
||||
"ERROR: failed to allocate buffer for subsampling results",511);
|
||||
pPriv->errorCode = HMNOMEMORY;
|
||||
return NULL;
|
||||
}
|
||||
resultdata[0] = len/sizeof(HistInt);
|
||||
hmdata = (HistInt *)ghttp_get_body(pPriv->syncRequest);
|
||||
for(i = 0; i < len/sizeof(HistInt); i++){
|
||||
resultdata[i+1] = ntohl(hmdata[i]);
|
||||
}
|
||||
return resultdata;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int SinqHttpSetHistogram(pHistDriver self, SConnection *pCon,
|
||||
int bank, int start, int end, HistInt *data){
|
||||
@@ -579,7 +618,8 @@ pHistDriver CreateSinqHttpDriver(pStringDict pOption){
|
||||
pNew->TryAndFixIt = SinqHttpFixIt;
|
||||
pNew->GetData = SinqHttpGetData;
|
||||
pNew->GetHistogram = SinqHttpGetHistogram;
|
||||
pNew->SetHistogram = SinqHttpSetHistogram;
|
||||
pNew->GetHistogram = SinqHttpGetHistogram;
|
||||
pNew->SubSample = SinqHttpSubSample;
|
||||
pNew->GetMonitor = SinqHttpGetMonitor;
|
||||
pNew->GetTime = SinqHttpGetTime;
|
||||
pNew->Preset = SinqHttpPreset;
|
||||
|
||||
Reference in New Issue
Block a user