diff --git a/amorstat.c b/amorstat.c index 7260f89..7671df5 100644 --- a/amorstat.c +++ b/amorstat.c @@ -19,6 +19,10 @@ An additional projection mode: onto the y -tof plane was added Mark Koennecke, June 2005 + + Support for new HTTP HM added + + Mark Koennecke, July 2006 --------------------------------------------------------------------------*/ #include #include @@ -526,6 +530,8 @@ pSINQHM pHist; SinqHMDriv *pTata; int iMax = -999999; + char hmCommand[256]; + HistInt *data = NULL; /* get size of our problem */ GetHistDim(self->pHM,iDim,&i3); @@ -580,6 +586,22 @@ return 0; } } + else if(self->iHTTP == 1) + { + + snprintf(hmCommand,255,"sum:2:0:%d",iDim[2]); + data = self->pHM->pDriv->SubSample(self->pHM->pDriv,pCon,0,hmCommand); + if(data == NULL) + { + SCWrite(pCon,"ERROR: failed to retrieve collapsed data from HM", eError); + return 0; + } + for(i = 2; i < length; i++) + { + iImage[i] = htonl(data[i-1]); + } + free(data); + } else { /* @@ -615,6 +637,8 @@ pSINQHM pHist; SinqHMDriv *pTata; int iMax = -999999; + char hmCommand[256]; + HistInt *data = NULL; /* get size of our problem */ GetHistDim(self->pHM,iDim,&i3); @@ -658,6 +682,21 @@ return 0; } } + else if(self->iHTTP == 1) + { + snprintf(hmCommand,255,"sum:0:0:%d", iDim[0]); + data = self->pHM->pDriv->SubSample(self->pHM->pDriv,pCon,0,hmCommand); + if(data == NULL) + { + SCWrite(pCon,"ERROR: failed to retrieve Y-projection from HM", eError); + return 0; + } + for(i = 2; i < length; i++) + { + iImage[i] = htonl(data[i-1]); + } + free(data); + } else { /* @@ -727,6 +766,14 @@ iData[i] = htonl(iData[i]); } } + else if(self->iHTTP == 1) + { + GetHistogramDirect(self->pHM,pCon,1,0,2*nTime,&iData[1],2*nTime*sizeof(HistInt)); + for(i = 1; i < length; i++) + { + iData[i] = htonl(iData[i]); + } + } else { /* @@ -763,6 +810,8 @@ pSINQHM pHist; SinqHMDriv *pTata; const float *fTime; + char hmCommand[256]; + HistInt *data = NULL; /* get histogram dimensions */ GetHistDim(self->pHM,iDim,&i3); @@ -875,6 +924,22 @@ return 0; } } + else if(self->iHTTP == 1) + { + snprintf(hmCommand,255,"sample:%d:%d:%d:%d:0:%d;sum:0:0:%d;sum:0:0:%d", + x1,x2,y1,y2,iDim[2]-1,x2-x1,y2-y1); + data = self->pHM->pDriv->SubSample(self->pHM->pDriv,pCon,0,hmCommand); + if(data == NULL) + { + SCWrite(pCon,"ERROR: failed to retrieve sub sampled data fromHM", eError); + return 0; + } + for(i = 1; i < iDim[2]+1; i++) + { + iSum[i] = htonl(data[i-1]); + } + free(data); + } else { /* do acouple of random numbers! */ @@ -957,6 +1022,21 @@ } return iRet; } + else if(strcmp(argv[1],"http") == 0) + { + if(argc > 2){ + if(!SCMatchRights(pCon,usMugger)){ + return 0; + } + self->iHTTP = atoi(argv[2]); + SCSendOK(pCon); + return 1; + } else { + snprintf(pBueffel,511,"amorstat.http = %d", self->iHTTP); + SCWrite(pCon,pBueffel,eValue); + return 1; + } + } else if(strcmp(argv[1],"sample") == 0) { if(argc < 7) diff --git a/amorstat.i b/amorstat.i index 5a24a64..f6173b3 100644 --- a/amorstat.i +++ b/amorstat.i @@ -23,6 +23,7 @@ pScanData pScan; pHistMem pHM; int iTOF; + int iHTTP; }AmorStat, *pAmorStat; diff --git a/amorstat.tex b/amorstat.tex index 8d29533..58bc0b5 100644 --- a/amorstat.tex +++ b/amorstat.tex @@ -41,6 +41,7 @@ $\langle$asdata {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ pScanData pScan;@\\ \mbox{}\verb@ pHistMem pHM;@\\ \mbox{}\verb@ int iTOF;@\\ +\mbox{}\verb@ int iHTTP;@\\ \mbox{}\verb@ }AmorStat, *pAmorStat;@\\ \mbox{}\verb@ @\\ \mbox{}\verb@@$\diamond$ diff --git a/amorstat.w b/amorstat.w index a8653d7..2945f24 100644 --- a/amorstat.w +++ b/amorstat.w @@ -36,6 +36,7 @@ In order to achieve all this some data structures are needed: pScanData pScan; pHistMem pHM; int iTOF; + int iHTTP; }AmorStat, *pAmorStat; @} diff --git a/ecb.c b/ecb.c index f66b0cb..ec190b4 100644 --- a/ecb.c +++ b/ecb.c @@ -284,7 +284,7 @@ int ECBAction(SConnection *pCon, SicsInterp *pSics, void *pData, pECB self = (pECB)pData; Z80_reg in, out; char pBuffer[80], pError[132]; - int status, iVal, func; + int status, iVal, func = 0; assert(self != NULL); diff --git a/libpsi.a b/libpsi.a index f710425..9d73e81 100644 Binary files a/libpsi.a and b/libpsi.a differ diff --git a/pimotor.c b/pimotor.c index f46c948..bdb07e5 100644 --- a/pimotor.c +++ b/pimotor.c @@ -693,11 +693,6 @@ { free(pM->drivername); } - /* get rid of parameter space */ - if(pM->ParArray) - { - ObParDelete(pM->ParArray); - } /* kill Descriptor */ DeleteDescriptor(pM->pDescriptor); diff --git a/sinqhttp.c b/sinqhttp.c index 0bd9ea4..ef4f6a0 100644 --- a/sinqhttp.c +++ b/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; diff --git a/tabledrive.c b/tabledrive.c index 70e1c48..19b7b14 100644 --- a/tabledrive.c +++ b/tabledrive.c @@ -225,8 +225,8 @@ static void liberateMotors(pTableDrive self, SConnection *pCon){ LLDnodeDataTo(self->motorTable,&moti); MotorGetPar(moti.pMot,"hardupperlim",&upper); MotorGetPar(moti.pMot,"hardlowerlim",&lower); - moti.pMot->ParArray[SLOW].fVal = lower; - moti.pMot->ParArray[SUPP].fVal = upper; + MotorSetPar(moti.pMot,pCon,"softupperlim",upper); + MotorSetPar(moti.pMot,pCon,"softlowerlim",lower); status = LLDnodePtr2Next(self->motorTable); } } @@ -249,8 +249,8 @@ static void closeMotors(pTableDrive self, SConnection *pCon){ upper = tdLower.upper + (self->currentPosition - targetCount)*diff; diff = tdUpper.lower - tdLower.lower; lower = tdLower.lower + (self->currentPosition - targetCount)*diff; - moti.pMot->ParArray[SLOW].fVal = lower; - moti.pMot->ParArray[SUPP].fVal = upper; + MotorSetPar(moti.pMot,pCon,"softupperlim",upper); + MotorSetPar(moti.pMot,pCon,"softlowerlim",lower); status = LLDnodePtr2Next(self->motorTable); } }