- Adapted amor status stuff to work with the new http based HM

This commit is contained in:
koennecke
2006-08-16 14:14:08 +00:00
parent 4b91d841d6
commit 928738dbd8
9 changed files with 131 additions and 13 deletions

View File

@ -19,6 +19,10 @@
An additional projection mode: onto the y -tof plane was added An additional projection mode: onto the y -tof plane was added
Mark Koennecke, June 2005 Mark Koennecke, June 2005
Support for new HTTP HM added
Mark Koennecke, July 2006
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -526,6 +530,8 @@
pSINQHM pHist; pSINQHM pHist;
SinqHMDriv *pTata; SinqHMDriv *pTata;
int iMax = -999999; int iMax = -999999;
char hmCommand[256];
HistInt *data = NULL;
/* get size of our problem */ /* get size of our problem */
GetHistDim(self->pHM,iDim,&i3); GetHistDim(self->pHM,iDim,&i3);
@ -580,6 +586,22 @@
return 0; 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 else
{ {
/* /*
@ -615,6 +637,8 @@
pSINQHM pHist; pSINQHM pHist;
SinqHMDriv *pTata; SinqHMDriv *pTata;
int iMax = -999999; int iMax = -999999;
char hmCommand[256];
HistInt *data = NULL;
/* get size of our problem */ /* get size of our problem */
GetHistDim(self->pHM,iDim,&i3); GetHistDim(self->pHM,iDim,&i3);
@ -658,6 +682,21 @@
return 0; 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 else
{ {
/* /*
@ -727,6 +766,14 @@
iData[i] = htonl(iData[i]); 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 else
{ {
/* /*
@ -763,6 +810,8 @@
pSINQHM pHist; pSINQHM pHist;
SinqHMDriv *pTata; SinqHMDriv *pTata;
const float *fTime; const float *fTime;
char hmCommand[256];
HistInt *data = NULL;
/* get histogram dimensions */ /* get histogram dimensions */
GetHistDim(self->pHM,iDim,&i3); GetHistDim(self->pHM,iDim,&i3);
@ -875,6 +924,22 @@
return 0; 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 else
{ {
/* do acouple of random numbers! */ /* do acouple of random numbers! */
@ -957,6 +1022,21 @@
} }
return iRet; 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) else if(strcmp(argv[1],"sample") == 0)
{ {
if(argc < 7) if(argc < 7)

View File

@ -23,6 +23,7 @@
pScanData pScan; pScanData pScan;
pHistMem pHM; pHistMem pHM;
int iTOF; int iTOF;
int iHTTP;
}AmorStat, *pAmorStat; }AmorStat, *pAmorStat;

View File

@ -41,6 +41,7 @@ $\langle$asdata {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ pScanData pScan;@\\ \mbox{}\verb@ pScanData pScan;@\\
\mbox{}\verb@ pHistMem pHM;@\\ \mbox{}\verb@ pHistMem pHM;@\\
\mbox{}\verb@ int iTOF;@\\ \mbox{}\verb@ int iTOF;@\\
\mbox{}\verb@ int iHTTP;@\\
\mbox{}\verb@ }AmorStat, *pAmorStat;@\\ \mbox{}\verb@ }AmorStat, *pAmorStat;@\\
\mbox{}\verb@ @\\ \mbox{}\verb@ @\\
\mbox{}\verb@@$\diamond$ \mbox{}\verb@@$\diamond$

View File

@ -36,6 +36,7 @@ In order to achieve all this some data structures are needed:
pScanData pScan; pScanData pScan;
pHistMem pHM; pHistMem pHM;
int iTOF; int iTOF;
int iHTTP;
}AmorStat, *pAmorStat; }AmorStat, *pAmorStat;
@} @}

2
ecb.c
View File

@ -284,7 +284,7 @@ int ECBAction(SConnection *pCon, SicsInterp *pSics, void *pData,
pECB self = (pECB)pData; pECB self = (pECB)pData;
Z80_reg in, out; Z80_reg in, out;
char pBuffer[80], pError[132]; char pBuffer[80], pError[132];
int status, iVal, func; int status, iVal, func = 0;
assert(self != NULL); assert(self != NULL);

BIN
libpsi.a

Binary file not shown.

View File

@ -693,11 +693,6 @@
{ {
free(pM->drivername); free(pM->drivername);
} }
/* get rid of parameter space */
if(pM->ParArray)
{
ObParDelete(pM->ParArray);
}
/* kill Descriptor */ /* kill Descriptor */
DeleteDescriptor(pM->pDescriptor); DeleteDescriptor(pM->pDescriptor);

View File

@ -33,6 +33,7 @@ static char statusdaq[] = {"/admin/textstatus.egi"};
static char gethm[] = {"/admin/readhmdata.egi"}; static char gethm[] = {"/admin/readhmdata.egi"};
static char configure[] = {"/admin/configure.egi"}; static char configure[] = {"/admin/configure.egi"};
static char preset[] = {"/admin/presethm.egi"}; static char preset[] = {"/admin/presethm.egi"};
static char subsample[] = {"/admin/processhmdata.egi"};
/*==================================================================== /*====================================================================
error codes error codes
======================================================================*/ ======================================================================*/
@ -44,6 +45,7 @@ static char preset[] = {"/admin/presethm.egi"};
#define SERVERERROR -706 #define SERVERERROR -706
#define BADSTATUS -707 #define BADSTATUS -707
#define BADAUTH -708 #define BADAUTH -708
#define HMNOMEMORY -709
/*===================================================================== /*=====================================================================
our driver private data structure our driver private data structure
======================================================================*/ ======================================================================*/
@ -125,6 +127,7 @@ static int sinqHttpGet(pSinqHttp self, char *request){
if(httpStatus != ghttp_done){ if(httpStatus != ghttp_done){
ghttp_close(self->syncRequest); ghttp_close(self->syncRequest);
sinqHttpGetPrepare(self,request); sinqHttpGetPrepare(self,request);
ghttp_prepare(self->syncRequest);
httpStatus = ghttp_process(self->syncRequest); httpStatus = ghttp_process(self->syncRequest);
} }
if(httpStatus != ghttp_done){ if(httpStatus != ghttp_done){
@ -441,9 +444,9 @@ static int SinqHttpFixIt(pHistDriver self, int code){
if(code == SERVERERROR){ if(code == SERVERERROR){
pPriv->failCount++; pPriv->failCount++;
if(pPriv->failCount > 2){ if(pPriv->failCount > 2){
return COTERM; return COTERM;
} else { } else {
return COREDO; return COREDO;
} }
} }
return COTERM; return COTERM;
@ -487,6 +490,42 @@ static int SinqHttpGetHistogram(pHistDriver self, SConnection *pCon,
} }
return 1; 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, static int SinqHttpSetHistogram(pHistDriver self, SConnection *pCon,
int bank, int start, int end, HistInt *data){ int bank, int start, int end, HistInt *data){
@ -579,7 +618,8 @@ pHistDriver CreateSinqHttpDriver(pStringDict pOption){
pNew->TryAndFixIt = SinqHttpFixIt; pNew->TryAndFixIt = SinqHttpFixIt;
pNew->GetData = SinqHttpGetData; pNew->GetData = SinqHttpGetData;
pNew->GetHistogram = SinqHttpGetHistogram; pNew->GetHistogram = SinqHttpGetHistogram;
pNew->SetHistogram = SinqHttpSetHistogram; pNew->GetHistogram = SinqHttpGetHistogram;
pNew->SubSample = SinqHttpSubSample;
pNew->GetMonitor = SinqHttpGetMonitor; pNew->GetMonitor = SinqHttpGetMonitor;
pNew->GetTime = SinqHttpGetTime; pNew->GetTime = SinqHttpGetTime;
pNew->Preset = SinqHttpPreset; pNew->Preset = SinqHttpPreset;

View File

@ -225,8 +225,8 @@ static void liberateMotors(pTableDrive self, SConnection *pCon){
LLDnodeDataTo(self->motorTable,&moti); LLDnodeDataTo(self->motorTable,&moti);
MotorGetPar(moti.pMot,"hardupperlim",&upper); MotorGetPar(moti.pMot,"hardupperlim",&upper);
MotorGetPar(moti.pMot,"hardlowerlim",&lower); MotorGetPar(moti.pMot,"hardlowerlim",&lower);
moti.pMot->ParArray[SLOW].fVal = lower; MotorSetPar(moti.pMot,pCon,"softupperlim",upper);
moti.pMot->ParArray[SUPP].fVal = upper; MotorSetPar(moti.pMot,pCon,"softlowerlim",lower);
status = LLDnodePtr2Next(self->motorTable); status = LLDnodePtr2Next(self->motorTable);
} }
} }
@ -249,8 +249,8 @@ static void closeMotors(pTableDrive self, SConnection *pCon){
upper = tdLower.upper + (self->currentPosition - targetCount)*diff; upper = tdLower.upper + (self->currentPosition - targetCount)*diff;
diff = tdUpper.lower - tdLower.lower; diff = tdUpper.lower - tdLower.lower;
lower = tdLower.lower + (self->currentPosition - targetCount)*diff; lower = tdLower.lower + (self->currentPosition - targetCount)*diff;
moti.pMot->ParArray[SLOW].fVal = lower; MotorSetPar(moti.pMot,pCon,"softupperlim",upper);
moti.pMot->ParArray[SUPP].fVal = upper; MotorSetPar(moti.pMot,pCon,"softlowerlim",lower);
status = LLDnodePtr2Next(self->motorTable); status = LLDnodePtr2Next(self->motorTable);
} }
} }