From 364abf90cf5ecffbdf32bb33d12bc60e89a7fc33 Mon Sep 17 00:00:00 2001 From: koennecke Date: Tue, 9 Mar 2010 13:12:03 +0000 Subject: [PATCH] - Fixed a singlex death when there was no lambda. Was a problem during shutdown when nothing works as it should - Made an attempt to have all error message printed on demand - Added a tricsswap feature to sinqhttp which swaps the data right for SICS - Edited speed for phytron driver - First attack on adding a misalignment calculation to tasub - Added a test protocol for scriptcontext which can be configured. --- sinqhttp.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/sinqhttp.c b/sinqhttp.c index ff4ed41..0d52dd8 100644 --- a/sinqhttp.c +++ b/sinqhttp.c @@ -61,6 +61,7 @@ typedef struct { int pause; int failCount; int asyncRunning; + int tricsswap; } sinqHttp, *pSinqHttp; /*------------------------------------------------------------------*/ static int sinqHttpGetPrepare(pSinqHttp self, char *request) @@ -153,7 +154,7 @@ static int sinqHttpGet(pSinqHttp self, char *request) static int SinqHttpConfigure(pHistDriver self, SConnection * pCon, pStringDict pOpt, SicsInterp * pSics) { - char hmname[512]; + char hmname[512], buffer[132]; char confCommand[512], url[512]; pSinqHttp pPriv = NULL; int status, iInit; @@ -203,6 +204,10 @@ static int SinqHttpConfigure(pHistDriver self, SConnection * pCon, } } + status = StringDictGet(pOpt,"tricsswap", buffer, sizeof(buffer)); + if(status == 1){ + pPriv->tricsswap = 1; + } /* actually do configure */ @@ -501,7 +506,37 @@ static int SinqHttpGetData(pHistDriver self, SConnection * pCon) */ return 1; } +/*------------------------------------------------------------------- + * This is an ugly hack to swap TRICS data into the + * correct order. + */ +static void swapTrics(HistInt *data, pHMdata hmdata, int length) +{ + int i,j, xdim, ydim; + HistInt *tmpData = NULL, *val; + /* + * do nothing if no match + */ + xdim = hmdata->iDim[0]; + ydim = hmdata->iDim[1]; + if(xdim*ydim < length){ + return; + } + tmpData = malloc(length*sizeof(HistInt)); + if(tmpData == NULL){ + return; + } + memcpy(tmpData, data, length*sizeof(HistInt)); + val = tmpData; + for(j = 0; j < ydim; j++){ + for(i = 0; i < xdim; i++){ + data[j*xdim+i] = *val; + val++; + } + } + free(tmpData); +} /*-------------------------------------------------------------------*/ static int SinqHttpGetHistogram(pHistDriver self, SConnection * pCon, int bank, int start, int end, @@ -533,6 +568,9 @@ static int SinqHttpGetHistogram(pHistDriver self, SConnection * pCon, for (i = 0; i < (end - start); i++) { data[i] = ntohl(hmdata[i]); } + if(pPriv->tricsswap == 1){ + swapTrics(data, self->data, end-start); + } return 1; }