Added a zebraswap in order to fix the zebra data issue

This commit is contained in:
2016-12-06 09:31:28 +01:00
parent 76bad754fa
commit 4369104480
3 changed files with 81 additions and 2 deletions

View File

@ -26,7 +26,7 @@ OBJ=psi.o buffer.o ruli.o sps.o pimotor.o \
pfeifferprot.o termprot.o phytron.o autowin.o eigera2.o \ pfeifferprot.o termprot.o phytron.o autowin.o eigera2.o \
jvlprot.o \ jvlprot.o \
eigermono.o sputterprot.o zwickroll.o astriumnet.o poldifold.o \ eigermono.o sputterprot.o zwickroll.o astriumnet.o poldifold.o \
epicsadapter.o epicsadapter.o zebraswap.o
.SECONDARY.: sanslirebin.c .SECONDARY.: sanslirebin.c

2
psi.c
View File

@ -125,7 +125,7 @@ static void AddPsiCommands(SicsInterp * pInter)
SCMD("MakeEigerMono", InitEigerMono); SCMD("MakeEigerMono", InitEigerMono);
PCMD("cnvrt", CnvrtAction); PCMD("cnvrt", CnvrtAction);
SCMD("MakeEpicsAdapter", MakeEpicsAdapter); SCMD("MakeEpicsAdapter", MakeEpicsAdapter);
PCMD("zebraswap", ZebraSwap);
/* /*
* Tcl 8.5 has implemented the clock command in tcl rather then C. * Tcl 8.5 has implemented the clock command in tcl rather then C.
* This includes the same command, backported from Tcl 8.4 * This includes the same command, backported from Tcl 8.4

79
zebraswap.c Normal file
View File

@ -0,0 +1,79 @@
/*
This is an ugly hack to swap histogram memory data on ZEBRA.
Ported over from sinqhttp.c. Fixing this properly would mean changes
to the HM code. Which in turn would affect AMOR and BOA too. I also
do not seem to need magic swaps at AMOR or BOA.....
copyright: see file COPYRIGHT
Mark Koennecke, December 2016
*/
#include <sics.h>
#include <histmem.h>
#include <sicshipadaba.h>
/*---------------------------------------------------------------*/
static void swapTrics(HistInt *data, int xdim, int ydim)
{
int x,y, length;
HistInt *tmpData = NULL, val;
length = xdim*ydim;
tmpData = malloc(length*sizeof(HistInt));
if(tmpData == NULL){
return;
}
memcpy(tmpData, data, length*sizeof(HistInt));
for(y = 0; y < ydim; y++){
for(x = 0; x < xdim; x++){
val = tmpData[x*ydim + y];
data[y*xdim+x] = val;
}
}
free(tmpData);
}
/*----------------------------------------------------------------*/
int ZebraSwap(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
int xdim, ydim, status;
pHdb dataNode = NULL;
hdbValue val;
if(argc < 4) {
SCWrite(pCon,"ERROR: insufficient number of argument to zebraswap\nUsage: zebraswap hmdatanode xdim ydim", eError);
return 0;
}
dataNode = FindHdbIntern(argv[1]);
if(dataNode == NULL){
SCPrintf(pCon,eError,"ERROR: data node %s not found", argv[1]);
return 0;
}
status = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&xdim);
if(status != TCL_OK){
SCPrintf(pCon,eError,"ERROR: failed to convert %s to integer", argv[2]);
return 0;
}
status = Tcl_GetInt(InterpGetTcl(pSics),argv[3],&ydim);
if(status != TCL_OK){
SCPrintf(pCon,eError,"ERROR: failed to convert %s to integer", argv[3]);
return 0;
}
val = dataNode->value;
if(val.dataType != HIPINTVARAR || val.arrayLength < xdim*ydim){
SCWrite(pCon,"ERROR: data type or dimension mismatch between node and parameters", eError);
return 0;
}
swapTrics((HistInt *)val.v.intArray,xdim,ydim);
SCSendOK(pCon);
return 1;
}