mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
merge conflict resolved from 4.0.0
This commit is contained in:
@ -146,19 +146,6 @@ typedef struct {
|
||||
} sls_detector_module;
|
||||
|
||||
|
||||
/**
|
||||
@short structure for a region of interest
|
||||
|
||||
xmin,xmax,ymin,ymax define the limits of the region
|
||||
*/
|
||||
typedef struct {
|
||||
int xmin; /**< is the roi xmin (in channel number) */
|
||||
int xmax; /**< is the roi xmax (in channel number)*/
|
||||
int ymin; /**< is the roi ymin (in channel number)*/
|
||||
int ymax; /**< is the roi ymax (in channel number)*/
|
||||
} ROI ;
|
||||
|
||||
|
||||
/* /\* */
|
||||
/* @short structure for a generic integer array */
|
||||
/* *\/ */
|
||||
|
@ -1,5 +1,6 @@
|
||||
/** API versions */
|
||||
#define APIRECEIVER 0x180718
|
||||
#define APIRECEIVER 0x180927
|
||||
#define APIEIGER 0x180820
|
||||
#define APIJUNGFRAU 0x180820
|
||||
#define APIGOTTHARD 0x180820
|
||||
#define APIJUNGFRAU 0x180925
|
||||
#define APIGOTTHARD 0x180928
|
||||
|
||||
|
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 548036a602123cb3c06bbf4f9a40c9acd6c527fc
|
||||
Revision: 349
|
||||
Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
|
||||
Revision: 350
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3988
|
||||
Last Changed Date: 2018-08-23 11:57:31.000000002 +0200 ./Makefile.virtual
|
||||
Last Changed Author: Gemma_Tinti
|
||||
Last Changed Rev: 3999
|
||||
Last Changed Date: 2018-09-28 14:11:53.000000002 +0200 ./Makefile.virtual
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "548036a602123cb3c06bbf4f9a40c9acd6c527fc"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3988
|
||||
#define GITDATE 0x20180823
|
||||
#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
|
||||
#define GITAUTH "Gemma_Tinti"
|
||||
#define GITREV 0x3999
|
||||
#define GITDATE 0x20180928
|
||||
#define GITBRANCH "developer"
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2
|
||||
Revision: 1992
|
||||
Branch: 3.3.0-rc
|
||||
Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
|
||||
Revision: 2040
|
||||
Branch: 4.0.0
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3941
|
||||
Last Changed Date: 2018-07-18 12:26:21.000000002 +0200 ./threadFiles/ThreadPool.o
|
||||
Last Changed Rev: 4020
|
||||
Last Changed Date: 2018-09-27 18:22:10.000000002 +0200 ./sharedMemory/SharedMemory.o
|
||||
|
@ -16,7 +16,7 @@ INSTMODE= 0777
|
||||
|
||||
|
||||
BINS = testlib_sharedlibc
|
||||
SRCS = server.c firmware_funcs.c server_funcs.c communication_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
SRCS = server.c firmware_funcs.c server_funcs.c communication_funcs.c mcb_funcs.c
|
||||
OBJS = $(SRCS:%.c=%.o)
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ versioning:
|
||||
$(PROGS): $(OBJS)
|
||||
# echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||
rm gotthardDetectorServer.gdb
|
||||
|
||||
|
||||
install: $(PROGS)
|
||||
|
@ -16,7 +16,7 @@ INSTMODE= 0777
|
||||
|
||||
|
||||
BINS = testlib_sharedlibc
|
||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
|
||||
OBJS = $(SRCS:%.c=%.o)
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
|
||||
PROGS= $(DESTDIR)/gotthardDetectorServer_virtual
|
||||
|
||||
|
||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
|
||||
OBJS = $(SRCS:%.c=%.o)
|
||||
|
||||
gotthardVirtualServer = $(PROGS)
|
||||
|
@ -4,10 +4,6 @@
|
||||
#include "mcb_funcs.h"
|
||||
#include "registers_g.h"
|
||||
|
||||
#ifdef SHAREDMEMORY
|
||||
#include "sharedmemory.h"
|
||||
#endif
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
@ -34,9 +30,7 @@ int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||
int storeInRAM=0;
|
||||
int ROI_flag=0;
|
||||
int adcConfigured=-1;
|
||||
u_int32_t *ram_values=NULL;
|
||||
volatile char *now_ptr=NULL;
|
||||
volatile u_int16_t *values;
|
||||
|
||||
int ram_size=0;
|
||||
|
||||
int64_t totalTime=1;
|
||||
@ -64,6 +58,8 @@ int slaveadcphase = 0;
|
||||
int rsttosw1delay = 2;
|
||||
int startacqdelay = 1;
|
||||
|
||||
int detectorFirstServer = 1;
|
||||
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
extern const int nChans;
|
||||
@ -187,9 +183,6 @@ int mapCSP0(void) {
|
||||
printf("CSPObase is 0x%llx \n",CSP0BASE);
|
||||
printf("CSPOBASE=from %llx to %llx\n",CSP0BASE,CSP0BASE+MEM_SIZE);
|
||||
|
||||
u_int32_t address;
|
||||
address = FIFO_DATA_REG_OFF;
|
||||
values=(u_int16_t*)(CSP0BASE+address*2);
|
||||
printf("statusreg=%08x\n",bus_r(STATUS_REG));
|
||||
printf("\n\n");
|
||||
return OK;
|
||||
@ -273,12 +266,20 @@ void setMasterSlaveConfiguration(){
|
||||
}
|
||||
else {
|
||||
cprintf(RED,"could not scan masterflags %s value from config file\n",value);
|
||||
fclose(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!detectorFirstServer) {
|
||||
cprintf(BLUE, "Server has been started up before. Ignoring rest of config file\n");
|
||||
fclose(fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(sscanf(value,"%d",&ival)<=0) {
|
||||
cprintf(RED,"could not scan patternphase %s value from config file\n",value);
|
||||
fclose(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -298,6 +299,7 @@ void setMasterSlaveConfiguration(){
|
||||
startacqdelay = ival;
|
||||
else {
|
||||
cprintf(RED,"could not scan parameter name %s from config file\n",key);
|
||||
fclose(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@ -384,6 +386,7 @@ int setPhaseShiftOnce(){
|
||||
//bus_w(addr,0x0); //clear the reg
|
||||
|
||||
if(reg==0){
|
||||
detectorFirstServer = 1;
|
||||
printf("\nImplementing phase shift of %d\n",phase_shift);
|
||||
for (i=1;i<phase_shift;i++) {
|
||||
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821
|
||||
@ -392,7 +395,7 @@ int setPhaseShiftOnce(){
|
||||
#ifdef VERBOSE
|
||||
printf("Multipupose reg now:%x\n",bus_r(addr));
|
||||
#endif
|
||||
}
|
||||
} else detectorFirstServer = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@ -839,18 +842,6 @@ u_int32_t testFpga(void) {
|
||||
}
|
||||
|
||||
|
||||
// for fpga test
|
||||
u_int32_t testRAM(void) {
|
||||
int result=OK;
|
||||
int i=0;
|
||||
allocateRAM();
|
||||
// while(i<100000) {
|
||||
memcpy((char*)ram_values, (char*)values, dataBytes);
|
||||
printf ("Testing RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, (unsigned int)(values), (unsigned int)(ram_values), dataBytes);
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
int getNModBoard() {
|
||||
return nModX;
|
||||
}
|
||||
@ -1261,7 +1252,6 @@ int setADC(int adc){
|
||||
|
||||
int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){
|
||||
|
||||
|
||||
#ifdef DDEBUG
|
||||
printf("Chip of Intrst Reg:%x\n",bus_r(CHIP_OF_INTRST_REG));
|
||||
printf("IP Packet Size:%d\n",ipPacketSize);
|
||||
@ -1492,11 +1482,7 @@ int startStateMachine(){
|
||||
//#endif
|
||||
cleanFifo();
|
||||
// fifoReset();
|
||||
now_ptr=(char*)ram_values;
|
||||
#ifdef SHAREDMEMORY
|
||||
write_stop_sm(0);
|
||||
write_status_sm("Started");
|
||||
#endif
|
||||
|
||||
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
|
||||
bus_w16(CONTROL_REG, 0x0);
|
||||
printf("statusreg=%08x\n",bus_r(STATUS_REG));
|
||||
@ -1572,31 +1558,12 @@ u_int32_t fifo_full(void)
|
||||
}
|
||||
|
||||
|
||||
u_int32_t* fifo_read_event()
|
||||
{
|
||||
#ifdef VIRTUAL
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("before looping\n");
|
||||
#endif
|
||||
volatile u_int32_t t = bus_r(LOOK_AT_ME_REG);
|
||||
|
||||
void waitForAcquisitionFinish(){
|
||||
volatile u_int32_t t = bus_r(LOOK_AT_ME_REG);
|
||||
#ifdef VERBOSE
|
||||
printf("lookatmereg=x%x\n",t);
|
||||
#endif
|
||||
/*
|
||||
while ((t&0x1)==0)
|
||||
{
|
||||
t = bus_r(LOOK_AT_ME_REG);
|
||||
if (!runBusy()){
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
while((t&0x1)==0) {
|
||||
while((t&0x1)==0) {
|
||||
if (runBusy()==0) {
|
||||
t = bus_r(LOOK_AT_ME_REG);
|
||||
if ((t&0x1)==0) {
|
||||
@ -1604,7 +1571,7 @@ u_int32_t* fifo_read_event()
|
||||
printf("no frame found - exiting ");
|
||||
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
#endif
|
||||
return NULL;
|
||||
return;
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
|
||||
@ -1613,38 +1580,12 @@ u_int32_t* fifo_read_event()
|
||||
}
|
||||
}
|
||||
t = bus_r(LOOK_AT_ME_REG);
|
||||
}
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
#endif
|
||||
|
||||
dma_memcpy(now_ptr,values ,dataBytes);
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
int a;
|
||||
for (a=0;a<8; a=a+2)
|
||||
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
||||
for (a=2554;a<2560; a=a+2)
|
||||
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
||||
printf("********\n");
|
||||
//memcpy(now_ptr, values, dataBytes);
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
printf("Copying to ptr %08x %d\n",(unsigned int)(now_ptr), dataBytes);
|
||||
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
#endif
|
||||
|
||||
if (storeInRAM>0) {
|
||||
now_ptr+=dataBytes;
|
||||
}
|
||||
return ram_values;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
u_int32_t* decode_data(int *datain)
|
||||
{
|
||||
u_int32_t *dataout;
|
||||
@ -1759,83 +1700,10 @@ int testBus() {
|
||||
|
||||
|
||||
int setStoreInRAM(int b) {
|
||||
if (b>0)
|
||||
storeInRAM=1;
|
||||
else
|
||||
storeInRAM=0;
|
||||
return allocateRAM();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int allocateRAM() {
|
||||
size_t size;
|
||||
u_int32_t nt, nf;
|
||||
nt=setTrains(-1);
|
||||
nf=setFrames(-1);
|
||||
if (nt==0) nt=1;
|
||||
if (nf==0) nf=1;
|
||||
// ret=clearRAM();
|
||||
if (storeInRAM) {
|
||||
size=dataBytes*nf*nt;
|
||||
if (size<dataBytes)
|
||||
size=dataBytes;
|
||||
} else
|
||||
size=dataBytes;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
|
||||
#endif
|
||||
|
||||
if (size==ram_size) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("RAM of size %d already allocated: nothing to be done\n",(int) size);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("reallocating ram %x\n",(unsigned int)ram_values);
|
||||
#endif
|
||||
// clearRAM();
|
||||
// ram_values=malloc(size);
|
||||
//+2 was added since dma_memcpy would switch the 16 bit values and the mem is 32 bit
|
||||
ram_values=realloc(ram_values,size)+2;
|
||||
|
||||
if (ram_values) {
|
||||
now_ptr=(char*)ram_values;
|
||||
#ifdef VERBOSE
|
||||
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
||||
#endif
|
||||
ram_size=size;
|
||||
return OK;
|
||||
} else {
|
||||
printf("could not allocate %d bytes\n",(int)size);
|
||||
if (storeInRAM==1) {
|
||||
printf("retrying\n");
|
||||
storeInRAM=0;
|
||||
size=dataBytes;
|
||||
ram_values=realloc(ram_values,size)+2;
|
||||
if (ram_values==NULL)
|
||||
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
|
||||
else {
|
||||
now_ptr=(char*)ram_values;
|
||||
ram_size=size;
|
||||
#ifdef VERBOSE
|
||||
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int configureADC(){
|
||||
@ -1857,7 +1725,7 @@ int configureADC(){
|
||||
|
||||
|
||||
// start point
|
||||
valw=0xff;
|
||||
valw=0xffffffff;
|
||||
bus_w(ADC_SPI_REG,(valw));
|
||||
|
||||
//chip sel bar down
|
||||
@ -1868,102 +1736,38 @@ int configureADC(){
|
||||
//cldwn
|
||||
valw=valw&(~(0x1<<cdx));
|
||||
bus_w(ADC_SPI_REG,valw);
|
||||
usleep(0);
|
||||
//usleep(0);
|
||||
|
||||
//write data (i)
|
||||
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx);
|
||||
bus_w(ADC_SPI_REG,valw);
|
||||
usleep(0);
|
||||
//usleep(0);
|
||||
|
||||
//clkup
|
||||
valw=valw+(0x1<<cdx);
|
||||
bus_w(ADC_SPI_REG,valw);
|
||||
usleep(0);
|
||||
//usleep(0);
|
||||
}
|
||||
|
||||
valw |= csmask;
|
||||
bus_w(ADC_SPI_REG,valw);
|
||||
//usleep(0);
|
||||
|
||||
// stop point =start point
|
||||
valw=valw&(~(0x1<<cdx));
|
||||
usleep(0);
|
||||
valw=0xff;
|
||||
bus_w(ADC_SPI_REG,(valw));
|
||||
|
||||
valw = 0xffffffff;
|
||||
bus_w(ADC_SPI_REG,(valw));
|
||||
|
||||
//usleep in between
|
||||
usleep(50000);
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
/*
|
||||
codata=0;
|
||||
codata=(0x14<<8)+(0x0); //command and value;
|
||||
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // start point
|
||||
valw=((0xffffffff&(~csmask)));bus_w(ADC_SPI_REG,valw); //chip sel bar down
|
||||
for (i=0;i<24;i++) {
|
||||
valw=valw&(~(0x1<<cdx));bus_w(ADC_SPI_REG,valw);usleep(0); //cldwn
|
||||
|
||||
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); bus_w(ADC_SPI_REG,valw); usleep(0); //write data (i)
|
||||
|
||||
valw=valw+(0x1<<cdx);bus_w(ADC_SPI_REG,valw); usleep(0); //clkup
|
||||
|
||||
}
|
||||
|
||||
valw=valw&(~(0x1<<cdx));usleep(0);
|
||||
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // stop point =start point
|
||||
|
||||
|
||||
|
||||
usleep(5000);
|
||||
|
||||
codata=0;
|
||||
codata=(0x08<<8)+(0x3); //command and value;Power modes(global) reset
|
||||
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // start point
|
||||
valw=((0xffffffff&(~csmask)));bus_w(ADC_SPI_REG,valw); //chip sel bar down
|
||||
for (i=0;i<24;i++) {
|
||||
valw=valw&(~(0x1<<cdx));bus_w(ADC_SPI_REG,valw);usleep(0); //cldwn
|
||||
|
||||
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); bus_w(ADC_SPI_REG,valw); usleep(0); //write data (i)
|
||||
valw=valw+(0x1<<cdx);bus_w(ADC_SPI_REG,valw); usleep(0); //clkup
|
||||
|
||||
}
|
||||
|
||||
valw=valw&(~(0x1<<cdx));usleep(0);
|
||||
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // stop point =start point
|
||||
|
||||
|
||||
|
||||
usleep(50000);
|
||||
codata=0;
|
||||
codata=(0x08<<8)+(0x0); //command and value;Power modes(global) reset
|
||||
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // start point
|
||||
valw=((0xffffffff&(~csmask)));bus_w(ADC_SPI_REG,valw); //chip sel bar down
|
||||
for (i=0;i<24;i++) {
|
||||
valw=valw&(~(0x1<<cdx));bus_w(ADC_SPI_REG,valw);usleep(0); //cldwn
|
||||
|
||||
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); bus_w(ADC_SPI_REG,valw); usleep(0); //write data (i)
|
||||
valw=valw+(0x1<<cdx);bus_w(ADC_SPI_REG,valw); usleep(0); //clkup
|
||||
|
||||
}
|
||||
|
||||
valw=valw&(~(0x1<<cdx));usleep(0);
|
||||
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // stop point =start point
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
int clearRAM() {
|
||||
if (ram_values) {
|
||||
//#ifdef VERBOSE
|
||||
//printf("clearing RAM 0x%x\n", ram_values);
|
||||
//#endif
|
||||
free(ram_values);
|
||||
ram_values=NULL;
|
||||
now_ptr=NULL;
|
||||
}
|
||||
//#ifdef VERBOSE
|
||||
//printf("done 0x%x\n", ram_values);
|
||||
//#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2111,113 +1915,7 @@ int resetCounterBlock(int startACQ){
|
||||
|
||||
|
||||
int calibratePedestal(int frames){
|
||||
printf("---------------------------\n");
|
||||
printf("In Calibrate Pedestal\n");
|
||||
int64_t framesBefore = getFrames();
|
||||
int64_t periodBefore = getPeriod();
|
||||
setFrames(frames);
|
||||
setPeriod(1000000);
|
||||
int dataret = OK;
|
||||
|
||||
double avg[1280];
|
||||
int numberFrames = 0;
|
||||
|
||||
int adc = 3;
|
||||
int adcCh = 3;
|
||||
int Ch = 3;
|
||||
|
||||
|
||||
int i = 0;
|
||||
for(i =0; i < 1280; i++){
|
||||
|
||||
avg[i] = 0.0;
|
||||
}
|
||||
|
||||
startReceiver(0);
|
||||
|
||||
startStateMachine();
|
||||
|
||||
while(dataret==OK){
|
||||
//got data
|
||||
if (fifo_read_event()) {
|
||||
dataret=OK;
|
||||
//sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
//sendDataOnly(file_des,dataretval,dataBytes);
|
||||
printf("received frame\n");
|
||||
|
||||
unsigned short *frame = (unsigned short *)now_ptr;
|
||||
|
||||
int a;
|
||||
for (a=0;a<1280; a++){
|
||||
//unsigned short v = (frame[a] << 8) + (frame[a] >> 8);
|
||||
// printf("%i: %i %i\n",a, frame[a],v);
|
||||
avg[a] += ((double)frame[a])/(double)frames;
|
||||
//if(frame[a] == 8191)
|
||||
// printf("ch %i: %u\n",a,frame[a]);
|
||||
}
|
||||
// printf("********\n");
|
||||
numberFrames++;
|
||||
}
|
||||
|
||||
//no more data or no data
|
||||
else {
|
||||
if(getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
printf("no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
printf("acquisition successfully finished\n");
|
||||
|
||||
}
|
||||
printf("dataret %d\n",dataret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//double nf = (double)numberFrames;
|
||||
for(i =0; i < 1280; i++){
|
||||
adc = i / 256;
|
||||
adcCh = (i - adc * 256) / 32;
|
||||
Ch = i - adc * 256 - adcCh * 32;
|
||||
adc--;
|
||||
double v2 = avg[i];
|
||||
avg[i] = avg[i]/ ((double)numberFrames/(double)frames);
|
||||
unsigned short v = (unsigned short)avg[i];
|
||||
printf("setting avg for channel %i(%i,%i,%i): %i (double= %f (%f))\t", i,adc,adcCh,Ch, v,avg[i],v2);
|
||||
v=i*100;
|
||||
ram_w16(DARK_IMAGE_REG,adc,adcCh,Ch,v-4096);
|
||||
if(ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch) != v-4096){
|
||||
printf("value is wrong (%i,%i,%i): %i \n",adc,adcCh,Ch, ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch));
|
||||
}
|
||||
}
|
||||
|
||||
/*for(adc = 1; adc < 5; adc++){
|
||||
for(adcCh = 0; adcCh < 8; adcCh++){
|
||||
for(Ch=0 ; Ch < 32; Ch++){
|
||||
int channel = (adc+1) * 32 * 8 + adcCh * 32 + Ch;
|
||||
double v2 = avg[channel];
|
||||
avg[channel] = avg[channel]/ ((double)numberFrames/(double)frames);
|
||||
unsigned short v = (unsigned short)avg[channel];
|
||||
printf("setting avg for channel %i: %i (double= %f (%f))\t", channel, v,avg[channel],v2);
|
||||
ram_w16(DARK_IMAGE_REG,adc,adcCh,Ch,v-4096);
|
||||
if(ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch) != v-4096){
|
||||
printf("value is wrong (%i,%i,%i): %i \n",adc,adcCh,Ch, ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
printf("frames: %i\n",numberFrames);
|
||||
printf("corrected avg by: %f\n",(double)numberFrames/(double)frames);
|
||||
|
||||
printf("restoring previous condition\n");
|
||||
setFrames(framesBefore);
|
||||
setPeriod(periodBefore);
|
||||
|
||||
// removed this functionlity as it requires reading via cpu
|
||||
printf("---------------------------\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ u_int32_t getFirmwareVersion();
|
||||
u_int32_t getFirmwareSVNVersion();
|
||||
int testFifos(void);
|
||||
u_int32_t testFpga(void);
|
||||
u_int32_t testRAM(void);
|
||||
int testBus(void);
|
||||
int setDigitalTestBit(int ival);
|
||||
|
||||
@ -128,8 +127,8 @@ u_int32_t fifoReadStatus();
|
||||
u_int32_t fifo_full(void);
|
||||
|
||||
|
||||
void waitForAcquisitionFinish();
|
||||
|
||||
u_int32_t* fifo_read_event();
|
||||
u_int32_t* decode_data(int* datain);
|
||||
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
|
||||
int setDynamicRange(int dr);
|
||||
@ -137,8 +136,7 @@ int getDynamicRange();
|
||||
int getNModBoard();
|
||||
int setNMod(int n);
|
||||
int setStoreInRAM(int b);
|
||||
int allocateRAM();
|
||||
int clearRAM();
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 548036a602123cb3c06bbf4f9a40c9acd6c527fc
|
||||
Revision: 236
|
||||
Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
|
||||
Revision: 237
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3988
|
||||
Last Changed Date: 2018-08-23 11:57:31.000000002 +0200 ./server_funcs.h
|
||||
Last Changed Author: Gemma_Tinti
|
||||
Last Changed Rev: 3999
|
||||
Last Changed Date: 2018-09-28 16:10:41.000000002 +0200 ./server_funcs.c
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "548036a602123cb3c06bbf4f9a40c9acd6c527fc"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3988
|
||||
#define GITDATE 0x20180823
|
||||
#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
|
||||
#define GITAUTH "Gemma_Tinti"
|
||||
#define GITREV 0x3999
|
||||
#define GITDATE 0x20180928
|
||||
#define GITBRANCH "developer"
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3
Executable file
BIN
slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3
Executable file
Binary file not shown.
@ -107,7 +107,6 @@ int initDetector() {
|
||||
// initChip(0, 0,ALLMOD);
|
||||
//nModX=n;
|
||||
//
|
||||
allocateRAM();
|
||||
|
||||
|
||||
return OK;
|
||||
@ -1831,205 +1830,19 @@ int testDataInOut(int num, int imod) {
|
||||
|
||||
|
||||
int testExtPulse(int imod) {
|
||||
int i, ichan, ichip, result=OK;
|
||||
int *val1;
|
||||
|
||||
printf("Testing counter for module %d\n", imod);
|
||||
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
putout("0000100000000000",ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
for (i=0; i<NCHAN; i++) {
|
||||
putout("0000000000000000",ALLMOD);
|
||||
putout("0000000000001000",ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
extPulse(1,ALLMOD);
|
||||
}
|
||||
clearSSregister(ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
|
||||
|
||||
// Readout with SM
|
||||
|
||||
//startStateMachine();
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
val1=(int*)(decode_data((int*)(fifo_read_event())));
|
||||
// val1=fifo_read_event();
|
||||
//imod=0;
|
||||
//for (imod=0; imod<nModX; imod++) {
|
||||
for (ichip=0; ichip<NCHIP; ichip++) {
|
||||
for (ichan=0; ichan<NCHAN; ichan++) {//
|
||||
if ((*(val1+ichan+(ichip+imod*NCHIP)*NCHAN))!=ichan) {
|
||||
result++;
|
||||
printf("Counter test: channel %d read %d instead of %d\n",ichan+(ichip+imod*NCHIP)*NCHAN, val1[ichan+(ichip+imod*NCHIP)*NCHAN], ichan);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
free(val1);
|
||||
if (result)
|
||||
return 1;
|
||||
else
|
||||
// reading via cPU doesnt work, so removed this functionality
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int testExtPulseMux(int imod, int ow) {
|
||||
|
||||
int i, ichan, ichip, result=0, ind, chipr=0;
|
||||
int *values, *v1;
|
||||
int vright,v;
|
||||
int nbit_mask=0xffffff;
|
||||
|
||||
printf("Testing counter for module %d, mux %d\n", imod, ow);
|
||||
setExposureTime(0);
|
||||
setFrames(1);
|
||||
setTrains(1);
|
||||
|
||||
|
||||
if (ow==2)
|
||||
nbit_mask=0xffff;
|
||||
else if (ow==3)
|
||||
nbit_mask=0xff;
|
||||
else if (ow==4)
|
||||
nbit_mask=0xf;
|
||||
else if (ow==5)
|
||||
nbit_mask=0x1;
|
||||
|
||||
|
||||
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
initChipWithProbes(0, ow,0,ALLMOD);
|
||||
// initChip(0, ow,ALLMOD);
|
||||
for (ichip=0; ichip<NCHIP; ichip++) {
|
||||
setSSregister(ALLMOD);
|
||||
for (i=0; i<NCHAN; i++) {
|
||||
putout("0000000000000000",ALLMOD);
|
||||
putout("0000000000001000",ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
extPulse(1,ALLMOD);
|
||||
}
|
||||
nextChip(ALLMOD);
|
||||
}
|
||||
setCSregister(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
|
||||
// Readout with SM
|
||||
|
||||
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
v1=(int*)(fifo_read_event());
|
||||
if (v1)
|
||||
values=(int*)(decode_data(v1));
|
||||
else {
|
||||
printf("no data found in fifos\n");
|
||||
return 1;
|
||||
}
|
||||
for (ichip=0; ichip<NCHIP; ichip++) {
|
||||
chipr=0;
|
||||
for (ichan=0; ichan<NCHAN; ichan++) {
|
||||
ind=ichan+(ichip+imod*NCHIP)*NCHAN;
|
||||
v=values[ind];
|
||||
vright=(ichan*(ichip+1))&nbit_mask;
|
||||
if (v!=vright) {
|
||||
result++;
|
||||
chipr++;
|
||||
printf("Counter test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*NCHIP)*NCHAN, ichip, v, vright);
|
||||
//break;
|
||||
}
|
||||
//printf("\n");
|
||||
}
|
||||
if (chipr)
|
||||
printf("Test Counter module %d chip%d mux %d: %d errors\n", imod,ichip, ow,chipr);
|
||||
}
|
||||
free(values);
|
||||
if (result)
|
||||
printf("Test Counter module %d mux %d: %d errors\n", imod,ow,result);
|
||||
|
||||
if (result)
|
||||
return 1;
|
||||
else
|
||||
// reading via cPU doesnt work, so removed this functionality
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int testDataInOutMux(int imod, int ow, int num) {
|
||||
|
||||
int ichan, ichip, result=0, chipr=0, ind;
|
||||
int vright,v;
|
||||
int nbit_mask=0xffffff;
|
||||
int *values, *v1;
|
||||
|
||||
printf("Testing data inout for module %d, mux %d, pattern 0x%x\n", imod, ow, num);
|
||||
setExposureTime(0);
|
||||
setFrames(1);
|
||||
setTrains(1);
|
||||
|
||||
|
||||
if (ow==2)
|
||||
nbit_mask=0xffff;
|
||||
else if (ow==3)
|
||||
nbit_mask=0xff;
|
||||
else if (ow==4)
|
||||
nbit_mask=0xf;
|
||||
else if (ow==5)
|
||||
nbit_mask=0x1;
|
||||
|
||||
vright=num&nbit_mask;
|
||||
|
||||
setCSregister(ALLMOD);
|
||||
//printf("Testin data in out\n");
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
initChannel(0,0,0,0,0,num,ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
initChipWithProbes(0, ow,0,ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
putout("0000000000000000",ALLMOD);
|
||||
|
||||
// Readout with SM
|
||||
|
||||
printf("mux %d\n",ow);
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
v1=(int*)(fifo_read_event());
|
||||
if (v1)
|
||||
values=(int*)(decode_data(v1));
|
||||
else {
|
||||
printf("no data found in fifos\n");
|
||||
return 1;
|
||||
}
|
||||
for (ichip=0; ichip<NCHIP; ichip++) {
|
||||
chipr=0;
|
||||
for (ichan=0; ichan<NCHAN; ichan++) {
|
||||
ind=ichan+(ichip+imod*NCHIP)*NCHAN;
|
||||
v=values[ind];
|
||||
if (v!=vright) {
|
||||
result++;
|
||||
chipr++;
|
||||
printf("DataInOut test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*NCHIP)*NCHAN, ichip, v, vright);
|
||||
//break;
|
||||
}
|
||||
//printf("\n");
|
||||
}
|
||||
if (chipr)
|
||||
printf("Test DatInOut module %d chip %d mux %d: %d errors\n", imod,ichip, ow,chipr);
|
||||
}
|
||||
if (result)
|
||||
printf("Test DatInOut module %d mux %d: %d errors\n", imod,ow,result);
|
||||
free(values);
|
||||
if (result)
|
||||
return 1;
|
||||
else
|
||||
// reading via cPU doesnt work, so removed this functionality
|
||||
return 0;
|
||||
|
||||
}
|
||||
@ -2486,7 +2299,7 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("\tGoing to enable adc: %d\n", adc);
|
||||
|
||||
//set rois for just 1 adc - take only 1st roi
|
||||
if(adc!=-1){
|
||||
@ -2495,10 +2308,14 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
|
||||
rois[0].ymin=-1;
|
||||
rois[0].ymax=-1;
|
||||
nROI = 1;
|
||||
printf("\tActual xmin:%d xmax:%d\n",rois[0].xmin,rois[0].xmax);
|
||||
}else
|
||||
nROI = 0;
|
||||
|
||||
if((arg[0].xmin!=rois[0].xmin)||(arg[0].xmax!=rois[0].xmax)||(arg[0].ymin!=rois[0].ymin)||(arg[0].ymax!=rois[0].ymax))
|
||||
if((n!=0) && ((arg[0].xmin!=rois[0].xmin)||
|
||||
(arg[0].xmax!=rois[0].xmax)||
|
||||
(arg[0].ymin!=rois[0].ymin)||
|
||||
(arg[0].ymax!=rois[0].ymax)))
|
||||
*ret=FAIL;
|
||||
if(n!=nROI)
|
||||
*ret=FAIL;
|
||||
@ -2508,9 +2325,11 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
|
||||
}
|
||||
|
||||
//#ifdef VERBOSE
|
||||
printf("Rois:\n");
|
||||
for( i=0;i<nROI;i++)
|
||||
printf("%d\t%d\t%d\t%d\n",rois[i].xmin,rois[i].xmax,rois[i].ymin,rois[i].ymax);
|
||||
if (nROI) {
|
||||
printf("Rois:\n");
|
||||
for( i=0;i<nROI;i++)
|
||||
printf("\t%d\t%d\t%d\t%d\n\n",rois[i].xmin,rois[i].xmax,rois[i].ymin,rois[i].ymax);
|
||||
}else printf("Rois: 0\n\n");
|
||||
//#endif
|
||||
*retvalsize = nROI;
|
||||
return rois;
|
||||
|
@ -47,8 +47,8 @@
|
||||
#define DEFAULT_PHASE_SHIFT 120
|
||||
#define DEFAULT_IP_PACKETSIZE 0x0522
|
||||
#define DEFAULT_UDP_PACKETSIZE 0x050E
|
||||
#define ADC1_IP_PACKETSIZE 256*2+14+20
|
||||
#define ADC1_UDP_PACKETSIZE 256*2+4+8+2
|
||||
#define ADC1_IP_PACKETSIZE (256*2+14+20)
|
||||
#define ADC1_UDP_PACKETSIZE (256*2+4+8+2)
|
||||
|
||||
#ifdef VIRTUAL
|
||||
#define DEBUGOUT
|
||||
|
@ -7,7 +7,6 @@
|
||||
#endif
|
||||
#include "firmware_funcs.h"
|
||||
#include "mcb_funcs.h"
|
||||
#include "trimming_funcs.h"
|
||||
#include "registers_g.h"
|
||||
#include "gitInfoGotthard.h"
|
||||
#include "AD9257.h" // include "commonServerFunctions.h"
|
||||
@ -82,11 +81,11 @@ int init_detector( int b) {
|
||||
printf("Initializing Detector\n");
|
||||
#endif
|
||||
testFpga();
|
||||
testRAM();
|
||||
|
||||
//gotthard specific
|
||||
setPhaseShiftOnce();
|
||||
configureADC();
|
||||
|
||||
setADC(-1); //already does setdaqreg and clean fifo
|
||||
setSettings(DYNAMICGAIN,-1);
|
||||
setDefaultDacs();
|
||||
@ -101,7 +100,7 @@ int init_detector( int b) {
|
||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
setMaster(GET_MASTER);
|
||||
setSynchronization(GET_SYNCHRONIZATION_MODE);
|
||||
startReceiver(0);
|
||||
startReceiver(1);
|
||||
setMasterSlaveConfiguration();
|
||||
}
|
||||
strcpy(mess,"dummy message");
|
||||
@ -709,9 +708,9 @@ int digital_test(int file_des) {
|
||||
case DETECTOR_FIRMWARE_TEST:
|
||||
retval=testFpga();
|
||||
break;
|
||||
case DETECTOR_MEMORY_TEST:
|
||||
/*case DETECTOR_MEMORY_TEST:
|
||||
ret=testRAM();
|
||||
break;
|
||||
break;*/
|
||||
case DETECTOR_BUS_TEST:
|
||||
retval=testBus();
|
||||
break;
|
||||
@ -1918,93 +1917,44 @@ int get_run_status(int file_des) {
|
||||
}
|
||||
|
||||
int read_frame(int file_des) {
|
||||
dataret = FAIL;
|
||||
strcpy(mess,"wait for read frame failed\n");
|
||||
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
#ifdef VERBOSE
|
||||
printf("dataret %d\n",dataret);
|
||||
#endif
|
||||
return dataret;
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
cprintf(RED,"%s\n",mess);
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
return dataret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (storeInRAM==0) {
|
||||
if ((dataretval=(char*)fifo_read_event())) {
|
||||
dataret=OK;
|
||||
#ifdef VERYVERBOSE
|
||||
printf("Sending ptr %x %d\n",(unsigned int)(dataretval), dataBytes);
|
||||
|
||||
#ifdef VIRTUAL
|
||||
dataret = FINISHED;
|
||||
strcpy(mess,"acquisition successfully finished\n");
|
||||
#else
|
||||
waitForAcquisitionFinish();
|
||||
|
||||
// set return value and message
|
||||
if(getFrames()>-2) {
|
||||
dataret = FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
cprintf(RED,"%s\n",mess);
|
||||
} else {
|
||||
dataret = FINISHED;
|
||||
sprintf(mess,"acquisition successfully finished\n");
|
||||
cprintf(GREEN,"%s",mess);
|
||||
|
||||
}
|
||||
#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
printf("sent %d bytes \n",dataBytes);
|
||||
printf("dataret OK\n");
|
||||
#endif
|
||||
return OK;
|
||||
} else {
|
||||
//might add delay????
|
||||
if(getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
printf("%s\n",mess);
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
sprintf(mess,"acquisition successfully finished\n");
|
||||
printf("%s\n",mess);
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
printf("%d %d %x %s\n",(int)(sizeof(mess)),(int)(strlen(mess)),(unsigned int)( mess),mess);
|
||||
#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("message sent %s\n",mess);
|
||||
#endif
|
||||
printf("dataret %d\n",dataret);
|
||||
return dataret;
|
||||
}
|
||||
} else {
|
||||
nframes=0;
|
||||
while(fifo_read_event()) {
|
||||
nframes++;
|
||||
}
|
||||
dataretval=(char*)ram_values;
|
||||
dataret=OK;
|
||||
#ifdef VERBOSE
|
||||
printf("sending data of %d frames\n",nframes);
|
||||
#endif
|
||||
for (iframes=0; iframes<nframes; iframes++) {
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
||||
#endif
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
dataretval+=dataBytes;
|
||||
}
|
||||
if (getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
printf("%s\n",mess);
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
sprintf(mess,"acquisition successfully finished\n");
|
||||
printf("%s\n",mess);
|
||||
if (differentClients)
|
||||
dataret=FORCE_UPDATE;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Frames left %d\n",(int)(getFrames()));
|
||||
#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
printf("dataret %d\n",dataret);
|
||||
return dataret;
|
||||
}
|
||||
printf("dataret %d\n",dataret);
|
||||
return dataret;
|
||||
|
||||
if (differentClients)
|
||||
dataret=FORCE_UPDATE;
|
||||
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
return dataret;
|
||||
}
|
||||
|
||||
|
||||
@ -2096,9 +2046,9 @@ int set_timer(int file_des) {
|
||||
printf(mess);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("setting timer %d to %lld ns\n",ind,tns);
|
||||
#endif
|
||||
//#endif
|
||||
if (ret==OK) {
|
||||
|
||||
if (differentClients==1 && lockStatus==1 && tns!=-1) {
|
||||
@ -2149,10 +2099,6 @@ int set_timer(int file_des) {
|
||||
if (ret!=OK) {
|
||||
printf(mess);
|
||||
printf("set timer failed\n");
|
||||
} else if (ind==FRAME_NUMBER) {
|
||||
ret=allocateRAM();
|
||||
if (ret!=OK)
|
||||
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
||||
}
|
||||
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
@ -2293,12 +2239,6 @@ int set_dynamic_range(int file_des) {
|
||||
//if (dr>=0 && retval!=dr) ret=FAIL;
|
||||
if (ret!=OK) {
|
||||
sprintf(mess,"set dynamic range failed\n");
|
||||
} else {
|
||||
ret=allocateRAM();
|
||||
if (ret!=OK)
|
||||
sprintf(mess,"Could not allocate RAM for the dynamic range selected\n");
|
||||
else if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
@ -2341,9 +2281,9 @@ int set_roi(int file_des) {
|
||||
ret=FAIL;
|
||||
}
|
||||
//#ifdef VERBOSE
|
||||
printf("Setting ROI to:");
|
||||
printf("\n\nSetting ROI: nroi=%d\n",nroi);
|
||||
for( i=0;i<nroi;i++)
|
||||
printf("%d\t%d\t%d\t%d\n",arg[i].xmin,arg[i].xmax,arg[i].ymin,arg[i].ymax);
|
||||
printf("\t%d\t%d\t%d\t%d\n",arg[i].xmin,arg[i].xmax,arg[i].ymin,arg[i].ymax);
|
||||
//#endif
|
||||
}
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
|
@ -1,39 +0,0 @@
|
||||
#include "sharedmemory.h"
|
||||
|
||||
struct statusdata *stdata;
|
||||
|
||||
int inism(int clsv) {
|
||||
|
||||
static int scansmid;
|
||||
|
||||
if (clsv==SMSV) {
|
||||
if ( (scansmid=shmget(SMKEY,1024,IPC_CREAT | 0666 ))==-1 ) {
|
||||
return -1;
|
||||
}
|
||||
if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
if (clsv==SMCL) {
|
||||
if ( (scansmid=shmget(SMKEY,0,0) )==-1 ) {
|
||||
return -3;
|
||||
}
|
||||
if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void write_status_sm(char *status) {
|
||||
strcpy(stdata->status,status);
|
||||
}
|
||||
|
||||
void write_stop_sm(int v) {
|
||||
stdata->stop=v;
|
||||
}
|
||||
|
||||
void write_runnumber_sm(int v) {
|
||||
stdata->runnumber=v;
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
#ifndef SM
|
||||
#define SM
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
//#include <asm/page.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* key for shared memory */
|
||||
#define SMKEY 10001
|
||||
|
||||
#define SMSV 1
|
||||
#define SMCL 2
|
||||
|
||||
|
||||
struct statusdata {
|
||||
int runnumber;
|
||||
int stop;
|
||||
char status[20];
|
||||
} ;
|
||||
|
||||
|
||||
/* for shared memory */
|
||||
|
||||
int inism(int clsv);
|
||||
void write_status_sm(char *status);
|
||||
void write_stop_sm(int v);
|
||||
void write_runnumber_sm(int v);
|
||||
|
||||
#endif
|
@ -1,749 +0,0 @@
|
||||
#ifndef PICASSOD
|
||||
#include "server_defs.h"
|
||||
#else
|
||||
#include "picasso_defs.h"
|
||||
#endif
|
||||
#include "trimming_funcs.h"
|
||||
#include "mcb_funcs.h"
|
||||
#include "firmware_funcs.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
extern int nModX;
|
||||
//extern int *values;
|
||||
|
||||
extern const int nChans;
|
||||
extern const int nChips;
|
||||
extern const int nDacs;
|
||||
extern const int nAdcs;
|
||||
|
||||
|
||||
int trim_fixed_settings(int countlim, int par2, int im)
|
||||
{
|
||||
|
||||
int retval=OK;
|
||||
#ifdef VERBOSE
|
||||
printf("Trimming with fixed settings\n");
|
||||
#endif
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
|
||||
if (par2<=0)
|
||||
retval=trim_with_level(countlim, im);
|
||||
else
|
||||
retval=trim_with_median(countlim,im);
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
int trim_with_noise(int countlim, int nsigma, int im)
|
||||
{
|
||||
|
||||
|
||||
int retval=OK, retval1=OK, retval2=OK;
|
||||
#ifdef VERBOSE
|
||||
printf("Trimming using noise\n");
|
||||
#endif
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
|
||||
/* threshold scan */
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("chosing vthresh and vtrim.....");
|
||||
#endif
|
||||
retval1=choose_vthresh_and_vtrim(countlim,nsigma, im);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("trimming with noise.....\n");
|
||||
#endif
|
||||
retval2=trim_with_level(countlim, im);
|
||||
|
||||
#ifdef DEBUGOUT
|
||||
printf("done\n");
|
||||
#endif
|
||||
if (retval1==OK && retval2==OK)
|
||||
retval=OK;
|
||||
else
|
||||
retval=FAIL;
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
int trim_with_beam(int countlim, int nsigma, int im) //rpc
|
||||
{
|
||||
|
||||
|
||||
int retval=OK, retval1=OK, retval2=OK;
|
||||
|
||||
printf("Trimming using beam\n");
|
||||
//return OK;
|
||||
#ifdef VIRTUAL
|
||||
printf("Trimming using beam\n");
|
||||
return OK;
|
||||
#endif
|
||||
/* threshold scan */
|
||||
#ifdef DEBUGOUT
|
||||
printf("chosing vthresh and vtrim.....");
|
||||
#endif
|
||||
|
||||
retval1=choose_vthresh_and_vtrim(countlim,nsigma,im);
|
||||
retval2=trim_with_median(TRIM_DR, im);
|
||||
|
||||
#ifdef DEBUGOUT
|
||||
printf("done\n");
|
||||
#endif
|
||||
|
||||
if (retval1==OK && retval2==OK)
|
||||
retval=OK;
|
||||
else
|
||||
retval=FAIL;
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int trim_improve(int maxit, int par2, int im) //rpc
|
||||
{
|
||||
|
||||
int retval=OK, retval1=OK, retval2=OK;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Improve the trimming\n");
|
||||
#endif
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
|
||||
|
||||
if (par2!=0 && im==ALLMOD)
|
||||
retval1=choose_vthresh();
|
||||
|
||||
retval2=trim_with_median(2*maxit+1, im);
|
||||
#ifdef DEBUGOUT
|
||||
printf("done\n");
|
||||
#endif
|
||||
if (retval1==OK && retval2==OK)
|
||||
retval=OK;
|
||||
else
|
||||
retval=FAIL;
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
int calcthr_from_vcal(int vcal) {
|
||||
int thrmin;
|
||||
//thrmin=140+3*vcal/5;
|
||||
thrmin=180+3*vcal/5;
|
||||
return thrmin;
|
||||
}
|
||||
|
||||
int calccal_from_vthr(int vthr) {
|
||||
int vcal;
|
||||
vcal=5*(vthr-140)/3;
|
||||
return vcal;
|
||||
}
|
||||
|
||||
int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
||||
int retval=OK;
|
||||
#ifdef MCB_FUNCS
|
||||
int modma, modmi, nm;
|
||||
int thr, thrstep=5, nthr=31;
|
||||
|
||||
int *fifodata;
|
||||
|
||||
double vthreshmean, vthreshSTDev;
|
||||
int *thrmi, *thrma;
|
||||
double c;
|
||||
//double b=BVTRIM;
|
||||
//double a=AVTRIM;
|
||||
int *trim;
|
||||
int ich, imod, ichan;
|
||||
int nvalid=0;
|
||||
u_int32_t *scan;
|
||||
int ithr;
|
||||
sls_detector_channel myChan;
|
||||
|
||||
|
||||
|
||||
setFrames(1);
|
||||
// setNMod(getNModBoard());
|
||||
|
||||
if (im==ALLMOD){
|
||||
modmi=0;
|
||||
modma=nModX;
|
||||
} else {
|
||||
modmi=im;
|
||||
modma=im+1;
|
||||
}
|
||||
nm=modma-modmi;
|
||||
|
||||
trim=malloc(sizeof(int)*nChans*nChips*nModX);
|
||||
thrmi=malloc(sizeof(int)*nModX);
|
||||
thrma=malloc(sizeof(int)*nModX);
|
||||
|
||||
|
||||
for (ich=0; ich<nChans*nChips*nm; ich++)
|
||||
trim[ich]=-1;
|
||||
/*
|
||||
setCSregister(im);
|
||||
setSSregister(im);
|
||||
initChannel(0,0,0,1,0,0,im);
|
||||
counterClear(im);
|
||||
clearSSregister(im);
|
||||
usleep(500);
|
||||
*/
|
||||
myChan.chan=-1;
|
||||
myChan.chip=-1;
|
||||
myChan.module=ALLMOD;
|
||||
myChan.reg=COMPARATOR_ENABLE;
|
||||
initChannelbyNumber(myChan);
|
||||
|
||||
|
||||
for (ithr=0; ithr<nthr; ithr++) {
|
||||
fifoReset();
|
||||
/* scanning threshold */
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
//commented out by dhanya thr=getDACbyIndexDACU(VTHRESH,imod);
|
||||
if (ithr==0) {
|
||||
thrmi[imod]=thr;
|
||||
//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
|
||||
} else
|
||||
;//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr+thrstep,imod);
|
||||
}
|
||||
|
||||
/* setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
initChannel(0,0,0,1,0,0,im);
|
||||
setDynamicRange(32);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
counterClear(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
usleep(500);
|
||||
startStateMachine();
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
fifodata=(int*)fifo_read_event();
|
||||
scan=decode_data(fifodata);
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
for (ichan=0; ichan<nChans*nChips; ichan++){
|
||||
ich=imod*nChips*nChans+ichan;
|
||||
if (scan[ich]>countlim && trim[ich]==-1) {
|
||||
//commented out by dhanya trim[ich]=getDACbyIndexDACU(VTHRESH,imod);
|
||||
#ifdef VERBOSE
|
||||
// printf("yes: %d %d %d\n",ich,ithr,scan[ich]);
|
||||
#endif
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
/* else {
|
||||
printf("no: %d %d %d\n",ich,ithr,scan[ich]);
|
||||
}*/
|
||||
#endif
|
||||
}
|
||||
}
|
||||
free(scan);
|
||||
}
|
||||
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
vthreshmean=0;
|
||||
vthreshSTDev=0;
|
||||
nvalid=0;
|
||||
//commented out by dhanya thrma[imod]=getDACbyIndexDACU(VTHRESH,imod);
|
||||
|
||||
for (ichan=0; ichan<nChans*nChips; ichan++){
|
||||
ich=imod*nChans*nChips+ichan;
|
||||
if(trim[ich]>thrmi[imod] && trim[ich]<thrma[imod]) {
|
||||
vthreshmean=vthreshmean+trim[ich];
|
||||
vthreshSTDev=vthreshSTDev+trim[ich]*trim[ich];
|
||||
nvalid++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nvalid>0) {
|
||||
vthreshmean=vthreshmean/nvalid;
|
||||
//commented out by dhanya vthreshSTDev=sqrt((vthreshSTDev/nvalid)-vthreshmean*vthreshmean);
|
||||
} else {
|
||||
vthreshmean=thrmi[imod];
|
||||
vthreshSTDev=nthr*thrstep;
|
||||
printf("No valid channel for module %d\n",imod);
|
||||
retval=FAIL;
|
||||
}
|
||||
|
||||
#ifdef DEBUGOUT
|
||||
printf("module= %d nvalid = %d mean=%f RMS=%f\n",imod, nvalid, vthreshmean,vthreshSTDev);
|
||||
#endif
|
||||
// *vthresh=round(vthreshmean-nsigma*vthreshSTDev);
|
||||
thr=(int)(vthreshmean-nsigma*vthreshSTDev);
|
||||
if (thr<0 || thr>(DAC_DR-1)) {
|
||||
thr=thrmi[imod]/2;
|
||||
printf("Can't find correct threshold for module %d\n",imod);
|
||||
retval=FAIL;
|
||||
}
|
||||
//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
|
||||
#ifdef VERBOSE
|
||||
printf("vthresh=%d \n",thr);
|
||||
#endif
|
||||
c=CVTRIM-2.*nsigma*vthreshSTDev/63.;
|
||||
//commented out by dhanya thr=(int)((-b-sqrt(b*b-4*a*c))/(2*a));
|
||||
if (thr<500 || thr>(DAC_DR-1)) {
|
||||
thr=750;
|
||||
printf("Can't find correct trimbit size for module %d\n",imod);
|
||||
retval=FAIL;
|
||||
}
|
||||
|
||||
//commented out by dhanya initDACbyIndexDACU(VTRIM,thr,imod);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("vtrim=%d \n",thr);
|
||||
#endif
|
||||
|
||||
}
|
||||
free(trim);
|
||||
free(thrmi);
|
||||
free(thrma);
|
||||
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int trim_with_level(int countlim, int im) {
|
||||
int ich, itrim, ichan, ichip, imod;
|
||||
u_int32_t *scan;
|
||||
int *inttrim;
|
||||
int modma, modmi, nm;
|
||||
int retval=OK;
|
||||
int *fifodata;
|
||||
sls_detector_channel myChan;
|
||||
printf("trimming module number %d", im);
|
||||
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
setFrames(1);
|
||||
// setNMod(getNModBoard());
|
||||
|
||||
if (im==ALLMOD){
|
||||
modmi=0;
|
||||
modma=nModX;
|
||||
} else {
|
||||
modmi=im;
|
||||
modma=im+1;
|
||||
}
|
||||
nm=modma-modmi;
|
||||
|
||||
inttrim=malloc(sizeof(int)*nChips*nChans*nModX);
|
||||
printf("countlim=%d\n",countlim);
|
||||
for (ich=0; ich<nChans*nChips*nModX; ich++)
|
||||
inttrim[ich]=-1;
|
||||
|
||||
for (itrim=0; itrim<TRIM_DR+1; itrim++) {
|
||||
fifoReset();
|
||||
printf("Trimbit %d\n",itrim);
|
||||
myChan.chan=-1;
|
||||
myChan.chip=-1;
|
||||
myChan.module=ALLMOD;
|
||||
myChan.reg=COMPARATOR_ENABLE|(itrim<<TRIMBIT_OFF);
|
||||
initChannelbyNumber(myChan);
|
||||
|
||||
/*
|
||||
setCSregister(im);
|
||||
setSSregister(im);
|
||||
initChannel(itrim,0,0,1,0,0,ALLMOD);
|
||||
setDynamicRange(32);
|
||||
*/
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
usleep(500);
|
||||
startStateMachine();
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
|
||||
fifodata=(int*)fifo_read_event();
|
||||
scan=decode_data(fifodata);
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
for (ichan=0; ichan<nChans*nChips; ichan++) {
|
||||
ich=ichan+imod*nChans*nChips;
|
||||
if (inttrim[ich]==-1) {
|
||||
if (scan[ich]>countlim){
|
||||
inttrim[ich]=itrim;
|
||||
if (scan[ich]>2*countlim && itrim>0) {
|
||||
//if (scan[ich]>2*countlim || itrim==0) {
|
||||
inttrim[ich]=itrim-1;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Channel %d trimbit %d counted %d (%08x) countlim %d\n",ich,itrim,scan[ich],fifodata[ich],countlim);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
/* else
|
||||
printf("Channel %d trimbit %d counted %d countlim %d\n",ich,itrim,scan[ich],countlim);*/
|
||||
#endif
|
||||
}
|
||||
}
|
||||
free(scan);
|
||||
}
|
||||
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
clearCSregister(imod);
|
||||
firstChip(im);
|
||||
for (ichip=0; ichip<nChips; ichip++) {
|
||||
clearSSregister(imod);
|
||||
for (ichan=0; ichan<nChans; ichan++) {
|
||||
nextStrip(imod);
|
||||
ich=ichan+imod*nChans*nChips+ichip*nChans;
|
||||
if (*(inttrim+ich)==-1) {
|
||||
*(inttrim+ich)=TRIM_DR;
|
||||
// printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
|
||||
retval=FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
// else
|
||||
// printf("channel %d trimbit %d\n",ich,*(inttrim+ich) );
|
||||
#endif
|
||||
initChannel(inttrim[ich],0,0,1,0,0,imod);
|
||||
}
|
||||
nextChip(imod);
|
||||
}
|
||||
}
|
||||
free(inttrim);
|
||||
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
|
||||
#define median(a,n) kth_smallest(a,n,(((n)&1)?((n)/2):(((n)/2)-1)))
|
||||
|
||||
|
||||
int kth_smallest(int *a, int n, int k)
|
||||
{
|
||||
register int i,j,l,m ;
|
||||
register double x ;
|
||||
|
||||
l=0 ; m=n-1 ;
|
||||
while (l<m) {
|
||||
x=a[k] ;
|
||||
i=l ;
|
||||
j=m ;
|
||||
do {
|
||||
while (a[i]<x) i++ ;
|
||||
while (x<a[j]) j-- ;
|
||||
if (i<=j) {
|
||||
ELEM_SWAP(a[i],a[j]) ;
|
||||
i++ ; j-- ;
|
||||
}
|
||||
} while (i<=j) ;
|
||||
if (j<k) l=i ;
|
||||
if (k<i) m=j ;
|
||||
}
|
||||
return a[k] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ave(int *a, int n)
|
||||
{
|
||||
int av=0,i;
|
||||
for (i=0; i<n; i++)
|
||||
av=av+((double)*(a+i))/((double)n);
|
||||
return av;
|
||||
}
|
||||
|
||||
|
||||
int choose_vthresh() {
|
||||
|
||||
int retval=OK;
|
||||
#ifdef MCB_FUNCS
|
||||
int imod, ichan;
|
||||
u_int32_t *scan, *scan1;
|
||||
int olddiff[nModX], direction[nModX];
|
||||
int med[nModX], med1[nModX], diff, media;
|
||||
int change_flag=1;
|
||||
int iteration=0;
|
||||
int maxiterations=10;
|
||||
int vthreshmean=0;
|
||||
int vthresh;
|
||||
int im=ALLMOD;
|
||||
int modma, modmi, nm;
|
||||
int *fifodata;
|
||||
|
||||
setFrames(1);
|
||||
// setNMod(getNModBoard());
|
||||
|
||||
if (im==ALLMOD){
|
||||
modmi=0;
|
||||
modma=nModX;
|
||||
} else {
|
||||
modmi=im;
|
||||
modma=im+1;
|
||||
}
|
||||
nm=modma-modmi;
|
||||
|
||||
|
||||
|
||||
setDynamicRange(32);
|
||||
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
usleep(500);
|
||||
startStateMachine();
|
||||
while (runBusy()) {
|
||||
//printf(".");
|
||||
}
|
||||
usleep(500);
|
||||
|
||||
fifodata=(int*)fifo_read_event();
|
||||
scan=decode_data(fifodata);
|
||||
//
|
||||
scan1=decode_data(fifodata);
|
||||
|
||||
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
//
|
||||
med[imod]=(int)median((int*)scan1+imod*nChans*nChips,nChans*nChips);
|
||||
med1[imod]=med[imod];
|
||||
//commented out by dhanya vthreshmean=vthreshmean+getDACbyIndexDACU(VTHRESH,imod);
|
||||
olddiff[imod]=0xffffff;
|
||||
direction[imod]=0;
|
||||
printf("Median of module %d=%d\n",imod,med[imod]);
|
||||
}
|
||||
vthreshmean=vthreshmean/nm;
|
||||
//media=median(scan,nChans*nChips*nModX);
|
||||
//printf("Median overall=%d\n",media);
|
||||
media=median(med1+modmi,nm);
|
||||
printf("Median of modules=%d\n",media);
|
||||
free(scan);
|
||||
free(scan1);
|
||||
|
||||
|
||||
while(change_flag && iteration<maxiterations) {
|
||||
|
||||
setDynamicRange(32);
|
||||
fifoReset();
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
usleep(500);
|
||||
startStateMachine();
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
|
||||
fifodata=(int*)fifo_read_event();
|
||||
scan=decode_data(fifodata);
|
||||
//
|
||||
scan1=decode_data(fifodata);
|
||||
|
||||
change_flag=0;
|
||||
printf("Vthresh iteration %3d 0f %3d\n",iteration, maxiterations);
|
||||
for (ichan=modmi; ichan<modma; ichan++) {
|
||||
med[ichan]=(int)median((int*)scan1+ichan*nChans*nChips,nChans*nChips);
|
||||
med1[imod]=med[imod];
|
||||
media=median(med1+modmi,nm);
|
||||
|
||||
diff=med[ichan]-media;
|
||||
if (direction[ichan]==0) {
|
||||
if (diff>0)
|
||||
direction[ichan]=1;
|
||||
else
|
||||
direction[ichan]=-1;
|
||||
}
|
||||
//commented out by dhanya vthresh=getDACbyIndexDACU(VTHRESH,imod);
|
||||
if ( direction[ichan]!=-3) {
|
||||
if (abs(diff)>abs(olddiff[ichan])) {
|
||||
vthresh=vthresh-direction[ichan];
|
||||
if (vthresh>(DAC_DR-1)) {
|
||||
vthresh=(DAC_DR-1);
|
||||
printf("can't equalize threshold for module %d\n", ichan);
|
||||
retval=FAIL;
|
||||
}
|
||||
if (vthresh<0) {
|
||||
vthresh=0;
|
||||
printf("can't equalize threshold for module %d\n", ichan);
|
||||
retval=FAIL;
|
||||
}
|
||||
direction[ichan]=-3;
|
||||
} else {
|
||||
vthresh=vthresh+direction[ichan];
|
||||
olddiff[ichan]=diff;
|
||||
change_flag=1;
|
||||
}
|
||||
//commented out by dhanya initDACbyIndex(VTHRESH,vthresh, ichan);
|
||||
}
|
||||
}
|
||||
iteration++;
|
||||
free(scan);
|
||||
free(scan1);
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int trim_with_median(int stop, int im) {
|
||||
|
||||
|
||||
int retval=OK;
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
int ichan, imod, ichip, ich;
|
||||
u_int32_t *scan, *scan1;
|
||||
int *olddiff, *direction;
|
||||
int med, diff;
|
||||
int change_flag=1;
|
||||
int iteration=0;
|
||||
int me[nModX], me1[nModX];
|
||||
int modma, modmi, nm;
|
||||
int trim;
|
||||
int *fifodata;
|
||||
|
||||
setFrames(1);
|
||||
// setNMod(getNModBoard());
|
||||
|
||||
if (im==ALLMOD){
|
||||
modmi=0;
|
||||
modma=nModX;
|
||||
} else {
|
||||
modmi=im;
|
||||
modma=im+1;
|
||||
}
|
||||
nm=modma-modmi;
|
||||
|
||||
olddiff=malloc(4*nModX*nChips*nChans);
|
||||
direction=malloc(4*nModX*nChips*nChans);
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
for (ichip=0; ichip<nChips; ichip++) {
|
||||
for (ich=0; ich<nChans; ich++) {
|
||||
ichan=imod*nChips*nChans+ichip*nChans+ich;
|
||||
direction[ichan]=0;
|
||||
olddiff[ichan]=0x0fffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
/********
|
||||
fifoReset();
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
usleep(500);
|
||||
startStateMachine();
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
scan=decode_data(fifo_read_event());
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
me[imod]=median(scan+imod*nChans*nChips,nChans*nChips);
|
||||
printf("Median of module %d=%d\n",imod,me[imod]);
|
||||
}
|
||||
med=median(me,nm);
|
||||
printf("median is %d\n",med);
|
||||
free(scan);
|
||||
**************/
|
||||
while(change_flag && iteration<stop) {
|
||||
|
||||
setDynamicRange(32);
|
||||
fifoReset();
|
||||
setCSregister(ALLMOD);
|
||||
setSSregister(ALLMOD);
|
||||
counterClear(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
usleep(500);
|
||||
startStateMachine();
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
fifodata=(int*)fifo_read_event();
|
||||
scan=decode_data(fifodata);
|
||||
scan1=decode_data(fifodata);
|
||||
|
||||
|
||||
|
||||
/********* calculates median every time ***********/
|
||||
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
me[imod]=median((int*)scan1+imod*nChans*nChips,nChans*nChips);
|
||||
me1[imod]=me[imod];
|
||||
printf("Median of module %d=%d\n",imod,me[imod]);
|
||||
}
|
||||
med=median(me1,nm);
|
||||
printf("median is %d\n",med);
|
||||
|
||||
change_flag=0;
|
||||
printf("Trimbits iteration %d of %d\n",iteration, stop);
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
for (ichip=0; ichip<nChips; ichip++) {
|
||||
selChip(ichip,imod);
|
||||
clearSSregister(imod);
|
||||
for (ich=0; ich<nChans; ich++) {
|
||||
ichan=imod*nChips*nChans+ichip*nChans+ich;
|
||||
nextStrip(imod);
|
||||
diff=scan[ichan]-me[imod];
|
||||
if (direction[ichan]==0) {
|
||||
if (diff>0) {
|
||||
direction[ichan]=1;
|
||||
} else {
|
||||
direction[ichan]=-1;
|
||||
}
|
||||
}
|
||||
if ( direction[ichan]!=-3) {
|
||||
if (abs(diff)>abs(olddiff[ichan])) {
|
||||
trim=getTrimbit(imod,ichip,ich)+direction[ichan];
|
||||
printf("%d old diff %d < new diff %d %d - trimbit %d\n",ichan, olddiff[ichan], diff, direction[ichan], trim);
|
||||
direction[ichan]=-3;
|
||||
} else {
|
||||
trim=getTrimbit(imod,ichip,ich)-direction[ichan];
|
||||
olddiff[ichan]=diff;
|
||||
change_flag=1;
|
||||
}
|
||||
if (trim>TRIM_DR) {
|
||||
trim=63;
|
||||
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
|
||||
retval=FAIL;
|
||||
}
|
||||
if (trim<0) {
|
||||
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
|
||||
trim=0;
|
||||
retval=FAIL;
|
||||
}
|
||||
initChannel(trim,0,0,1,0,0,imod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
iteration++;
|
||||
free(scan);
|
||||
free(scan1);
|
||||
}
|
||||
free(olddiff);
|
||||
free(direction);
|
||||
#endif
|
||||
return retval;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#ifndef TRIMMING_FUNCS_H
|
||||
#define TRIMMING_FUNCS_H
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
int trim_fixed_settings(int countlim, int par2, int imod);
|
||||
int trim_with_noise(int countlim, int nsigma, int imod);
|
||||
int trim_with_beam(int countlim, int nsigma, int imod);
|
||||
int trim_improve(int maxit, int par2, int imod);
|
||||
int calcthr_from_vcal(int vcal);
|
||||
int calccal_from_vthr(int vthr);
|
||||
int choose_vthresh_and_vtrim(int countlim, int nsigma, int imod);
|
||||
|
||||
int choose_vthresh();
|
||||
int trim_with_level(int countlim, int imod);
|
||||
int trim_with_median(int stop, int imod);
|
||||
int calcthr_from_vcal(int vcal);
|
||||
int calccal_from_vthr(int vthr);
|
||||
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 548036a602123cb3c06bbf4f9a40c9acd6c527fc
|
||||
Revision: 162
|
||||
Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
|
||||
Revision: 163
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3988
|
||||
Last Changed Date: 2018-08-23 11:57:31.000000002 +0200 ./RegisterDefs.h
|
||||
Last Changed Author: Gemma_Tinti
|
||||
Last Changed Rev: 3999
|
||||
Last Changed Date: 2018-09-28 14:11:53.000000002 +0200 ./RegisterDefs.h
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "548036a602123cb3c06bbf4f9a40c9acd6c527fc"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3988
|
||||
#define GITDATE 0x20180823
|
||||
#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
|
||||
#define GITAUTH "Gemma_Tinti"
|
||||
#define GITREV 0x3999
|
||||
#define GITDATE 0x20180928
|
||||
#define GITBRANCH "developer"
|
||||
|
@ -43,12 +43,12 @@ multiSlsDetector::multiSlsDetector(int id, bool verify, bool update)
|
||||
|
||||
multiSlsDetector::~multiSlsDetector() {
|
||||
// delete zmq sockets first
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
zmqSocket.clear();
|
||||
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
detectors.clear();
|
||||
@ -101,12 +101,12 @@ T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)())
|
||||
return minusOneIfDifferent(values);
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::callDetectorMember(string (slsDetector::*somefunc)()) {
|
||||
string concatenatedValue, firstValue;
|
||||
std::string multiSlsDetector::callDetectorMember(std::string (slsDetector::*somefunc)()) {
|
||||
std::string concatenatedValue, firstValue;
|
||||
bool valueNotSame = false;
|
||||
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
string thisValue = (detectors[idet]->*somefunc)();
|
||||
std::string thisValue = (detectors[idet]->*somefunc)();
|
||||
;
|
||||
if (detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask() | (1 << idet));
|
||||
@ -347,14 +347,14 @@ double* multiSlsDetector::decodeData(int* datain, int& nn, double* fdata) {
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::writeDataFile(string fname, double* data, double* err,
|
||||
int multiSlsDetector::writeDataFile(std::string fname, double* data, double* err,
|
||||
double* ang, char dataformat, int nch) {
|
||||
#ifdef VERBOSE
|
||||
cout << "using overloaded multiSlsDetector function to write formatted data file "
|
||||
<< getTotalNumberOfChannels() << endl;
|
||||
#endif
|
||||
|
||||
ofstream outfile;
|
||||
std::ofstream outfile;
|
||||
int choff = 0, off = 0; //idata,
|
||||
double *pe = err, *pa = ang;
|
||||
int nch_left = nch, n; //, nd;
|
||||
@ -365,7 +365,7 @@ int multiSlsDetector::writeDataFile(string fname, double* data, double* err,
|
||||
if (data == NULL)
|
||||
return FAIL;
|
||||
|
||||
outfile.open(fname.c_str(), ios_base::out);
|
||||
outfile.open(fname.c_str(), std::ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
|
||||
for (unsigned int i = 0; i < detectors.size(); ++i) {
|
||||
@ -399,8 +399,8 @@ int multiSlsDetector::writeDataFile(string fname, double* data, double* err,
|
||||
}
|
||||
}
|
||||
|
||||
int multiSlsDetector::writeDataFile(string fname, int* data) {
|
||||
ofstream outfile;
|
||||
int multiSlsDetector::writeDataFile(std::string fname, int* data) {
|
||||
std::ofstream outfile;
|
||||
int choff = 0, off = 0;
|
||||
#ifdef VERBOSE
|
||||
cout << "using overloaded multiSlsDetector function to write raw data file " << endl;
|
||||
@ -409,7 +409,7 @@ int multiSlsDetector::writeDataFile(string fname, int* data) {
|
||||
if (data == NULL)
|
||||
return FAIL;
|
||||
|
||||
outfile.open(fname.c_str(), ios_base::out);
|
||||
outfile.open(fname.c_str(), std::ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
for (unsigned int i = 0; i < detectors.size(); ++i) {
|
||||
#ifdef VERBOSE
|
||||
@ -430,22 +430,22 @@ int multiSlsDetector::writeDataFile(string fname, int* data) {
|
||||
}
|
||||
}
|
||||
|
||||
int multiSlsDetector::readDataFile(string fname, double* data, double* err,
|
||||
int multiSlsDetector::readDataFile(std::string fname, double* data, double* err,
|
||||
double* ang, char dataformat) {
|
||||
#ifdef VERBOSE
|
||||
cout << "using overloaded multiSlsDetector function to read formatted data file " << endl;
|
||||
#endif
|
||||
|
||||
ifstream infile;
|
||||
std::ifstream infile;
|
||||
int iline = 0;
|
||||
string str;
|
||||
std::string str;
|
||||
int choff = 0, off = 0;
|
||||
double *pe = err, *pa = ang;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Opening file " << fname << std::endl;
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
|
||||
for (unsigned int i = 0; i < detectors.size(); ++i) {
|
||||
@ -469,19 +469,19 @@ int multiSlsDetector::readDataFile(string fname, double* data, double* err,
|
||||
return iline;
|
||||
}
|
||||
|
||||
int multiSlsDetector::readDataFile(string fname, int* data) {
|
||||
int multiSlsDetector::readDataFile(std::string fname, int* data) {
|
||||
#ifdef VERBOSE
|
||||
cout << "using overloaded multiSlsDetector function to read raw data file " << endl;
|
||||
#endif
|
||||
ifstream infile;
|
||||
std::ifstream infile;
|
||||
int iline = 0;
|
||||
string str;
|
||||
std::string str;
|
||||
int choff = 0, off = 0;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Opening file " << fname << std::endl;
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
|
||||
for (unsigned int i = 0; i < detectors.size(); ++i) {
|
||||
@ -501,17 +501,17 @@ int multiSlsDetector::readDataFile(string fname, int* data) {
|
||||
}
|
||||
|
||||
|
||||
string multiSlsDetector::getErrorMessage(int& critical) {
|
||||
std::string multiSlsDetector::getErrorMessage(int& critical) {
|
||||
int64_t multiMask, slsMask = 0;
|
||||
string retval = "";
|
||||
std::string retval = "";
|
||||
char sNumber[100];
|
||||
critical = 0;
|
||||
|
||||
multiMask = getErrorMask();
|
||||
if (multiMask) {
|
||||
if (multiMask & MULTI_DETECTORS_NOT_ADDED) {
|
||||
retval.append("Detectors not added:\n" + string(getNotAddedList()) +
|
||||
string("\n"));
|
||||
retval.append("Detectors not added:\n" + std::string(getNotAddedList()) +
|
||||
std::string("\n"));
|
||||
critical = 1;
|
||||
}
|
||||
if (multiMask & MULTI_HAVE_DIFFERENT_VALUES) {
|
||||
@ -529,13 +529,13 @@ string multiSlsDetector::getErrorMessage(int& critical) {
|
||||
if (multiMask & (1 << idet)) {
|
||||
//append detector id
|
||||
sprintf(sNumber, "%d", idet);
|
||||
retval.append("Detector " + string(sNumber) + string(":\n"));
|
||||
retval.append("Detector " + std::string(sNumber) + std::string(":\n"));
|
||||
//get sls det error mask
|
||||
slsMask = detectors[idet]->getErrorMask();
|
||||
#ifdef VERYVERBOSE
|
||||
//append sls det error mask
|
||||
sprintf(sNumber, "0x%lx", slsMask);
|
||||
retval.append("Error Mask " + string(sNumber) + string("\n"));
|
||||
retval.append("Error Mask " + std::string(sNumber) + std::string("\n"));
|
||||
#endif
|
||||
//get the error critical level
|
||||
if ((slsMask > 0xFFFFFFFF) | critical)
|
||||
@ -610,7 +610,7 @@ slsDetector* multiSlsDetector::getSlsDetector(unsigned int pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
slsDetector *multiSlsDetector::operator()(int pos) {
|
||||
slsDetector *multiSlsDetector::operator()(int pos) const {
|
||||
if (pos >= 0 && pos < (int)detectors.size())
|
||||
return detectors[pos];
|
||||
return NULL;
|
||||
@ -643,7 +643,7 @@ void multiSlsDetector::freeSharedMemory(int multiId) {
|
||||
|
||||
void multiSlsDetector::freeSharedMemory() {
|
||||
// clear zmq vector
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
zmqSocket.clear();
|
||||
@ -652,7 +652,7 @@ void multiSlsDetector::freeSharedMemory() {
|
||||
clearAllErrorMask();
|
||||
|
||||
// clear sls detector vector shm
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
(*it)->freeSharedMemory();
|
||||
delete (*it);
|
||||
}
|
||||
@ -687,7 +687,7 @@ std::string multiSlsDetector::getUserDetails() {
|
||||
//type
|
||||
sstream<< "\nType: ";
|
||||
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it)
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it)
|
||||
sstream<< (*it)->sgetDetectorsType() << "+";
|
||||
//PID
|
||||
sstream << "\nPID: " << thisMultiDetector->lastPID
|
||||
@ -695,7 +695,7 @@ std::string multiSlsDetector::getUserDetails() {
|
||||
<< "\nUser: " << thisMultiDetector->lastUser
|
||||
<< "\nDate: " << thisMultiDetector->lastDate << endl;
|
||||
|
||||
string s = sstream.str();
|
||||
std::string s = sstream.str();
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -876,7 +876,7 @@ void multiSlsDetector::initializeMembers(bool verify) {
|
||||
badFFList = NULL;
|
||||
|
||||
//multiSlsDetector
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
zmqSocket.clear();
|
||||
@ -888,7 +888,7 @@ void multiSlsDetector::initializeMembers(bool verify) {
|
||||
detectors.push_back(sdet);
|
||||
} catch (...) {
|
||||
// clear detectors list
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
detectors.clear();
|
||||
@ -951,21 +951,21 @@ void multiSlsDetector::setHostname(const char* name) {
|
||||
}
|
||||
|
||||
|
||||
string multiSlsDetector::getHostname(int pos) {
|
||||
std::string multiSlsDetector::getHostname(int pos) {
|
||||
return concatResultOrPos(&slsDetector::getHostname, pos);
|
||||
}
|
||||
|
||||
void multiSlsDetector::addMultipleDetectors(const char* name) {
|
||||
size_t p1 = 0;
|
||||
string temp = string(name);
|
||||
std::string temp = std::string(name);
|
||||
size_t p2 = temp.find('+', p1);
|
||||
//single
|
||||
if (p2 == string::npos) {
|
||||
if (p2 == std::string::npos) {
|
||||
addSlsDetector(temp);
|
||||
}
|
||||
// multi
|
||||
else {
|
||||
while(p2 != string::npos) {
|
||||
while(p2 != std::string::npos) {
|
||||
addSlsDetector(temp.substr(p1, p2-p1));
|
||||
temp = temp.substr(p2 + 1);
|
||||
p2 = temp.find('+');
|
||||
@ -982,7 +982,7 @@ void multiSlsDetector::addSlsDetector (std::string s) {
|
||||
#ifdef VERBOSE
|
||||
cout << "Adding detector " << s << endl;
|
||||
#endif
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
if ((*it)->getHostname((it-detectors.begin())) == s) {
|
||||
cout << "Detector " << s << "already part of the multiDetector!" << endl
|
||||
<< "Remove it before adding it back in a new position!" << endl;
|
||||
@ -1048,7 +1048,7 @@ void multiSlsDetector::createThreadPool() {
|
||||
threadpool = new ThreadPool(numthreads);
|
||||
switch (threadpool->initialize_threadpool()) {
|
||||
case 0:
|
||||
cerr << "Failed to initialize thread pool!" << endl;
|
||||
std::cerr << "Failed to initialize thread pool!" << endl;
|
||||
throw ThreadpoolException();
|
||||
case 1:
|
||||
#ifdef VERBOSE
|
||||
@ -1089,7 +1089,7 @@ void multiSlsDetector::getNumberOfDetectors(int& nx, int& ny) {
|
||||
|
||||
int multiSlsDetector::getNMods() {
|
||||
int nm = 0;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
nm += (*it)->getNMods();
|
||||
}
|
||||
return nm;
|
||||
@ -1097,7 +1097,7 @@ int multiSlsDetector::getNMods() {
|
||||
|
||||
int multiSlsDetector::getNMod(dimension d) {
|
||||
int nm = 0;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
nm += (*it)->getNMod(d);
|
||||
}
|
||||
return nm;
|
||||
@ -1105,7 +1105,7 @@ int multiSlsDetector::getNMod(dimension d) {
|
||||
|
||||
int multiSlsDetector::getMaxMods() {
|
||||
int ret = 0;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
ret += (*it)->getMaxMods();
|
||||
}
|
||||
return ret;
|
||||
@ -1113,7 +1113,7 @@ int multiSlsDetector::getMaxMods() {
|
||||
|
||||
int multiSlsDetector::getMaxMod(dimension d) {
|
||||
int ret = 0, ret1;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
ret1 = (*it)->getNMaxMod(d);
|
||||
#ifdef VERBOSE
|
||||
cout << "detector " << (it-detectors.begin()) << " maxmods " <<
|
||||
@ -1130,7 +1130,7 @@ int multiSlsDetector::getMaxMod(dimension d) {
|
||||
|
||||
int multiSlsDetector::getMaxNumberOfModules(dimension d) {
|
||||
int ret = 0;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
ret += (*it)->getMaxNumberOfModules(d);
|
||||
}
|
||||
return ret;
|
||||
@ -1181,7 +1181,7 @@ int multiSlsDetector::getChansPerMod(int imod) {
|
||||
|
||||
int multiSlsDetector::getTotalNumberOfChannels() {
|
||||
thisMultiDetector->numberOfChannels = 0;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
thisMultiDetector->numberOfChannels += (*it)->getTotalNumberOfChannels();
|
||||
}
|
||||
return thisMultiDetector->numberOfChannels;
|
||||
@ -1197,7 +1197,7 @@ int multiSlsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) {
|
||||
|
||||
int multiSlsDetector::getMaxNumberOfChannels() {
|
||||
thisMultiDetector->maxNumberOfChannels = 0;
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
thisMultiDetector->maxNumberOfChannels += (*it)->getMaxNumberOfChannels();
|
||||
}
|
||||
return thisMultiDetector->maxNumberOfChannels;
|
||||
@ -1401,10 +1401,10 @@ int multiSlsDetector::setOnline(int off) {
|
||||
}
|
||||
|
||||
|
||||
string multiSlsDetector::checkOnline() {
|
||||
string offlineDetectors = "";
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
string tmp = (*it)->checkOnline();
|
||||
std::string multiSlsDetector::checkOnline() {
|
||||
std::string offlineDetectors = "";
|
||||
for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
std::string tmp = (*it)->checkOnline();
|
||||
if (!tmp.empty())
|
||||
offlineDetectors += tmp + "+";
|
||||
}
|
||||
@ -1420,7 +1420,7 @@ int multiSlsDetector::lockServer(int p) {
|
||||
return callDetectorMember(&slsDetector::lockServer, p);
|
||||
}
|
||||
|
||||
string multiSlsDetector::getLastClientIP() {
|
||||
std::string multiSlsDetector::getLastClientIP() {
|
||||
return callDetectorMember(&slsDetector::getLastClientIP);
|
||||
}
|
||||
|
||||
@ -1434,26 +1434,26 @@ int multiSlsDetector::exitServer() {
|
||||
return ival;
|
||||
}
|
||||
|
||||
int multiSlsDetector::readConfigurationFile(string const fname) {
|
||||
int multiSlsDetector::readConfigurationFile(std::string const fname) {
|
||||
|
||||
freeSharedMemory();
|
||||
setupMultiDetector();
|
||||
|
||||
|
||||
multiSlsDetectorClient* cmd;
|
||||
string ans;
|
||||
string str;
|
||||
ifstream infile;
|
||||
std::string ans;
|
||||
std::string str;
|
||||
std::ifstream infile;
|
||||
int iargval;
|
||||
int interrupt = 0;
|
||||
char* args[1000];
|
||||
|
||||
char myargs[1000][1000];
|
||||
|
||||
string sargname, sargval;
|
||||
std::string sargname, sargval;
|
||||
int iline = 0;
|
||||
std::cout << "config file name " << fname << std::endl;
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
|
||||
while (infile.good() and interrupt == 0) {
|
||||
@ -1463,7 +1463,7 @@ int multiSlsDetector::readConfigurationFile(string const fname) {
|
||||
++iline;
|
||||
|
||||
// remove comments that come after
|
||||
if (str.find('#') != string::npos)
|
||||
if (str.find('#') != std::string::npos)
|
||||
str.erase(str.find('#'));
|
||||
#ifdef VERBOSE
|
||||
std::cout << "string:" << str << std::endl;
|
||||
@ -1474,7 +1474,7 @@ int multiSlsDetector::readConfigurationFile(string const fname) {
|
||||
#endif
|
||||
continue;
|
||||
} else {
|
||||
istringstream ssstr(str);
|
||||
std::istringstream ssstr(str);
|
||||
iargval = 0;
|
||||
while (ssstr.good()) {
|
||||
ssstr >> sargname;
|
||||
@ -1524,9 +1524,9 @@ int multiSlsDetector::readConfigurationFile(string const fname) {
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::writeConfigurationFile(string const fname) {
|
||||
int multiSlsDetector::writeConfigurationFile(std::string const fname) {
|
||||
|
||||
string names[] = {
|
||||
std::string names[] = {
|
||||
"detsizechan",
|
||||
"hostname",
|
||||
"master",
|
||||
@ -1551,10 +1551,10 @@ int multiSlsDetector::writeConfigurationFile(string const fname) {
|
||||
}
|
||||
int ret = OK, ret1 = OK;
|
||||
|
||||
ofstream outfile;
|
||||
std::ofstream outfile;
|
||||
int iline = 0;
|
||||
|
||||
outfile.open(fname.c_str(), ios_base::out);
|
||||
outfile.open(fname.c_str(), std::ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
|
||||
slsDetectorCommand* cmd = new slsDetectorCommand(this);
|
||||
@ -1610,7 +1610,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname) {
|
||||
|
||||
|
||||
|
||||
string multiSlsDetector::getSettingsFile() {
|
||||
std::string multiSlsDetector::getSettingsFile() {
|
||||
return callDetectorMember(&slsDetector::getSettingsFile);
|
||||
}
|
||||
|
||||
@ -1774,14 +1774,14 @@ slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings
|
||||
}
|
||||
|
||||
|
||||
string multiSlsDetector::getSettingsDir() {
|
||||
std::string multiSlsDetector::getSettingsDir() {
|
||||
return callDetectorMember(&slsDetector::getSettingsDir);
|
||||
}
|
||||
|
||||
|
||||
string multiSlsDetector::setSettingsDir(string s) {
|
||||
std::string multiSlsDetector::setSettingsDir(std::string s) {
|
||||
|
||||
if (s.find('+') == string::npos) {
|
||||
if (s.find('+') == std::string::npos) {
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
detectors[idet]->setSettingsDir(s);
|
||||
if (detectors[idet]->getErrorMask())
|
||||
@ -1791,7 +1791,7 @@ string multiSlsDetector::setSettingsDir(string s) {
|
||||
size_t p1 = 0;
|
||||
size_t p2 = s.find('+', p1);
|
||||
int id = 0;
|
||||
while (p2 != string::npos) {
|
||||
while (p2 != std::string::npos) {
|
||||
detectors[id]->setSettingsDir(s.substr(p1, p2 - p1));
|
||||
if (detectors[id]->getErrorMask())
|
||||
setErrorMask(getErrorMask() | (1 << id));
|
||||
@ -1805,13 +1805,13 @@ string multiSlsDetector::setSettingsDir(string s) {
|
||||
return getSettingsDir();
|
||||
}
|
||||
|
||||
string multiSlsDetector::getCalDir() {
|
||||
std::string multiSlsDetector::getCalDir() {
|
||||
return callDetectorMember(&slsDetector::getCalDir);
|
||||
}
|
||||
|
||||
string multiSlsDetector::setCalDir(string s) {
|
||||
std::string multiSlsDetector::setCalDir(std::string s) {
|
||||
|
||||
if (s.find('+') == string::npos) {
|
||||
if (s.find('+') == std::string::npos) {
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
detectors[idet]->setCalDir(s);
|
||||
if (detectors[idet]->getErrorMask())
|
||||
@ -1821,7 +1821,7 @@ string multiSlsDetector::setCalDir(string s) {
|
||||
size_t p1 = 0;
|
||||
size_t p2 = s.find('+', p1);
|
||||
int id = 0;
|
||||
while (p2 != string::npos) {
|
||||
while (p2 != std::string::npos) {
|
||||
|
||||
if (detectors[id]) {
|
||||
detectors[id]->setCalDir(s.substr(p1, p2 - p1));
|
||||
@ -1839,7 +1839,7 @@ string multiSlsDetector::setCalDir(string s) {
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
int multiSlsDetector::loadSettingsFile(std::string fname, int imod) {
|
||||
int ret = OK;
|
||||
|
||||
// single
|
||||
@ -1864,7 +1864,7 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
int* iret[detectors.size()];
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
iret[idet] = new int(OK);
|
||||
Task* task = new Task(new func2_t<int, string, int>(&slsDetector::loadSettingsFile,
|
||||
Task* task = new Task(new func2_t<int, std::string, int>(&slsDetector::loadSettingsFile,
|
||||
detectors[idet], fname, imod, iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
@ -1884,7 +1884,7 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int multiSlsDetector::saveSettingsFile(string fname, int imod) {
|
||||
int multiSlsDetector::saveSettingsFile(std::string fname, int imod) {
|
||||
int id = -1, im = -1, ret;
|
||||
|
||||
if (decodeNMod(imod, id, im) >= 0) {
|
||||
@ -1905,7 +1905,7 @@ int multiSlsDetector::saveSettingsFile(string fname, int imod) {
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
int multiSlsDetector::loadCalibrationFile(std::string fname, int imod) {
|
||||
int ret = OK;
|
||||
|
||||
// single
|
||||
@ -1931,7 +1931,7 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
if (detectors[idet]) {
|
||||
iret[idet] = new int(OK);
|
||||
Task* task = new Task(new func2_t<int, string, int>(&slsDetector::loadCalibrationFile,
|
||||
Task* task = new Task(new func2_t<int, std::string, int>(&slsDetector::loadCalibrationFile,
|
||||
detectors[idet], fname, imod, iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
@ -1954,7 +1954,7 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int multiSlsDetector::saveCalibrationFile(string fname, int imod) {
|
||||
int multiSlsDetector::saveCalibrationFile(std::string fname, int imod) {
|
||||
int id = -1, im = -1, ret;
|
||||
if (decodeNMod(imod, id, im) >= 0) {
|
||||
if (id < 0 || id >= (int)detectors.size())
|
||||
@ -2458,7 +2458,7 @@ int* multiSlsDetector::getDataFromDetector() {
|
||||
int nodatadet = -1;
|
||||
int nodatadetectortype = false;
|
||||
detectorType types = getDetectorsType();
|
||||
if (types == EIGER || types == JUNGFRAU) {
|
||||
if (types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX) {
|
||||
nodatadetectortype = true;
|
||||
}
|
||||
|
||||
@ -3030,21 +3030,21 @@ uint32_t multiSlsDetector::clearBit(uint32_t addr, int n) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
string multiSlsDetector::setNetworkParameter(networkParameter p, string s) {
|
||||
std::string multiSlsDetector::setNetworkParameter(networkParameter p, std::string s) {
|
||||
|
||||
if (s.find('+') == string::npos) {
|
||||
if (s.find('+') == std::string::npos) {
|
||||
|
||||
if (!threadpool) {
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return getNetworkParameter(p);
|
||||
} else {
|
||||
string* sret[detectors.size()];
|
||||
std::string* sret[detectors.size()];
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
if (p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT)
|
||||
s.append("multi\0");
|
||||
sret[idet] = new string("error");
|
||||
Task* task = new Task(new func2_t<string, networkParameter,
|
||||
string>(&slsDetector::setNetworkParameter,
|
||||
sret[idet] = new std::string("error");
|
||||
Task* task = new Task(new func2_t<std::string, networkParameter,
|
||||
std::string>(&slsDetector::setNetworkParameter,
|
||||
detectors[idet], p, s, sret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
@ -3063,7 +3063,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s) {
|
||||
size_t p1 = 0;
|
||||
size_t p2 = s.find('+', p1);
|
||||
int id = 0;
|
||||
while (p2 != string::npos) {
|
||||
while (p2 != std::string::npos) {
|
||||
detectors[id]->setNetworkParameter(p, s.substr(p1, p2 - p1));
|
||||
if (detectors[id]->getErrorMask())
|
||||
setErrorMask(getErrorMask() | (1 << id));
|
||||
@ -3078,18 +3078,18 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s) {
|
||||
return getNetworkParameter(p);
|
||||
}
|
||||
|
||||
string multiSlsDetector::getNetworkParameter(networkParameter p) {
|
||||
string s0 = "", s1 = "", s;
|
||||
string ans = "";
|
||||
std::string multiSlsDetector::getNetworkParameter(networkParameter p) {
|
||||
std::string s0 = "", s1 = "", s;
|
||||
std::string ans = "";
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
s = detectors[idet]->getNetworkParameter(p);
|
||||
if (detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask() | (1 << idet));
|
||||
|
||||
if (s0 == "")
|
||||
s0 = s + string("+");
|
||||
s0 = s + std::string("+");
|
||||
else
|
||||
s0 += s + string("+");
|
||||
s0 += s + std::string("+");
|
||||
|
||||
if (s1 == "")
|
||||
s1 = s;
|
||||
@ -3168,13 +3168,13 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::loadImageToDetector(imageType index, string const fname) {
|
||||
int multiSlsDetector::loadImageToDetector(imageType index, std::string const fname) {
|
||||
|
||||
int ret = -100, ret1;
|
||||
short int imageVals[thisMultiDetector->numberOfChannels];
|
||||
|
||||
ifstream infile;
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
std::ifstream infile;
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
#ifdef VERBOSE
|
||||
std::cout << std::endl
|
||||
@ -3204,11 +3204,11 @@ int multiSlsDetector::loadImageToDetector(imageType index, string const fname) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int multiSlsDetector::writeCounterBlockFile(string const fname, int startACQ) {
|
||||
int multiSlsDetector::writeCounterBlockFile(std::string const fname, int startACQ) {
|
||||
int ret = OK, ret1 = OK;
|
||||
short int arg[thisMultiDetector->numberOfChannels];
|
||||
ofstream outfile;
|
||||
outfile.open(fname.c_str(), ios_base::out);
|
||||
std::ofstream outfile;
|
||||
outfile.open(fname.c_str(), std::ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
#ifdef VERBOSE
|
||||
std::cout << std::endl
|
||||
@ -3872,7 +3872,7 @@ int multiSlsDetector::setStoragecellStart(int pos) {
|
||||
return parallelCallDetectorMember(&slsDetector::setStoragecellStart, pos);
|
||||
}
|
||||
|
||||
int multiSlsDetector::programFPGA(string fname) {
|
||||
int multiSlsDetector::programFPGA(std::string fname) {
|
||||
int ret = OK, ret1 = OK;
|
||||
|
||||
for (unsigned int i = 0; i < detectors.size(); ++i) {
|
||||
@ -4173,14 +4173,14 @@ int multiSlsDetector::rateCorrect(double* datain, double* errin, double* dataout
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setFlatFieldCorrection(string fname) {
|
||||
int multiSlsDetector::setFlatFieldCorrection(std::string fname) {
|
||||
double* data = new double[thisMultiDetector->numberOfChannels];
|
||||
double* ffcoefficients = new double[thisMultiDetector->numberOfChannels];
|
||||
double* fferrors = new double[thisMultiDetector->numberOfChannels];
|
||||
char ffffname[MAX_STR_LENGTH * 2];
|
||||
int nch;
|
||||
if (fname == "default") {
|
||||
fname = string(thisMultiDetector->flatFieldFile);
|
||||
fname = std::string(thisMultiDetector->flatFieldFile);
|
||||
}
|
||||
|
||||
thisMultiDetector->correctionMask &= ~(1 << FLAT_FIELD_CORRECTION);
|
||||
@ -4200,7 +4200,7 @@ int multiSlsDetector::setFlatFieldCorrection(string fname) {
|
||||
std::cout << "Setting flat field correction from file " << fname << std::endl;
|
||||
#endif
|
||||
sprintf(ffffname, "%s/%s", thisMultiDetector->flatFieldDir, fname.c_str());
|
||||
nch = readDataFile(string(ffffname), data);
|
||||
nch = readDataFile(std::string(ffffname), data);
|
||||
|
||||
if (nch > thisMultiDetector->numberOfChannels)
|
||||
nch = thisMultiDetector->numberOfChannels;
|
||||
@ -4298,7 +4298,7 @@ int multiSlsDetector::flatFieldCorrect(double* datain, double* errin, double* da
|
||||
return 0;
|
||||
}
|
||||
|
||||
int multiSlsDetector::setBadChannelCorrection(string fname) {
|
||||
int multiSlsDetector::setBadChannelCorrection(std::string fname) {
|
||||
int badlist[MAX_BADCHANS];
|
||||
int nbad = 0;
|
||||
int ret = 0;
|
||||
@ -4306,7 +4306,7 @@ int multiSlsDetector::setBadChannelCorrection(string fname) {
|
||||
cout << thisMultiDetector->badChanFile << endl;
|
||||
|
||||
if (fname == "default")
|
||||
fname = string(thisMultiDetector->badChanFile);
|
||||
fname = std::string(thisMultiDetector->badChanFile);
|
||||
|
||||
ret = setBadChannelCorrection(fname, nbad, badlist);
|
||||
//#ifdef VERBOSE
|
||||
@ -4428,11 +4428,11 @@ int multiSlsDetector::getBadChannelCorrection(int* bad) {
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::readAngularConversionFile(string fname) {
|
||||
int multiSlsDetector::readAngularConversionFile(std::string fname) {
|
||||
|
||||
ifstream infile;
|
||||
std::ifstream infile;
|
||||
//int nm=0;
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
@ -4451,11 +4451,11 @@ int multiSlsDetector::readAngularConversionFile(string fname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int multiSlsDetector::writeAngularConversion(string fname) {
|
||||
int multiSlsDetector::writeAngularConversion(std::string fname) {
|
||||
|
||||
ofstream outfile;
|
||||
std::ofstream outfile;
|
||||
// int nm=0;
|
||||
outfile.open(fname.c_str(), ios_base::out);
|
||||
outfile.open(fname.c_str(), std::ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
@ -4548,8 +4548,8 @@ int multiSlsDetector::setReceiverOnline(int off) {
|
||||
return thisMultiDetector->receiverOnlineFlag;
|
||||
}
|
||||
|
||||
string multiSlsDetector::checkReceiverOnline() {
|
||||
string retval1 = "", retval;
|
||||
std::string multiSlsDetector::checkReceiverOnline() {
|
||||
std::string retval1 = "", retval;
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
retval = detectors[idet]->checkReceiverOnline();
|
||||
if (!retval.empty()) {
|
||||
@ -4564,7 +4564,7 @@ int multiSlsDetector::lockReceiver(int lock) {
|
||||
return callDetectorMember(&slsDetector::lockReceiver, lock);
|
||||
}
|
||||
|
||||
string multiSlsDetector::getReceiverLastClientIP() {
|
||||
std::string multiSlsDetector::getReceiverLastClientIP() {
|
||||
return callDetectorMember(&slsDetector::getReceiverLastClientIP);
|
||||
}
|
||||
|
||||
@ -4583,9 +4583,9 @@ std::string multiSlsDetector::getFilePath() {
|
||||
return setFilePath();
|
||||
}
|
||||
|
||||
string multiSlsDetector::setFilePath(string s) {
|
||||
std::string multiSlsDetector::setFilePath(std::string s) {
|
||||
|
||||
string ret = "errorerror", ret1;
|
||||
std::string ret = "errorerror", ret1;
|
||||
for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
|
||||
ret1 = detectors[idet]->setFilePath(s);
|
||||
if (detectors[idet]->getErrorMask())
|
||||
@ -4603,9 +4603,9 @@ std::string multiSlsDetector::getFileName() {
|
||||
return setFileName();
|
||||
}
|
||||
|
||||
string multiSlsDetector::setFileName(string s) {
|
||||
std::string multiSlsDetector::setFileName(std::string s) {
|
||||
|
||||
string ret = "error";
|
||||
std::string ret = "error";
|
||||
int posmax = detectors.size();
|
||||
|
||||
if (!s.empty()) {
|
||||
@ -4616,12 +4616,12 @@ string multiSlsDetector::setFileName(string s) {
|
||||
|
||||
if (!threadpool) {
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return string("");
|
||||
return std::string("");
|
||||
} else {
|
||||
string* sret[detectors.size()];
|
||||
std::string* sret[detectors.size()];
|
||||
for (int idet = 0; idet < posmax; ++idet) {
|
||||
sret[idet] = new string("error");
|
||||
Task* task = new Task(new func1_t<string, string>(&slsDetector::setFileName,
|
||||
sret[idet] = new std::string("error");
|
||||
Task* task = new Task(new func1_t<std::string, std::string>(&slsDetector::setFileName,
|
||||
detectors[idet], s, sret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
@ -4928,7 +4928,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
|
||||
if (destroy) {
|
||||
cprintf(MAGENTA, "Going to destroy data sockets\n");
|
||||
//close socket
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
(*it)->Close();
|
||||
delete(*it);
|
||||
}
|
||||
@ -5010,7 +5010,7 @@ void multiSlsDetector::readFrameFromReceiver() {
|
||||
uint32_t size = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
float bytesPerPixel = 0;
|
||||
// header info every header
|
||||
string currentFileName = "";
|
||||
std::string currentFileName = "";
|
||||
uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, currentFileIndex = -1;
|
||||
uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, flippedDataX = -1;
|
||||
|
||||
@ -5078,11 +5078,11 @@ void multiSlsDetector::readFrameFromReceiver() {
|
||||
currentFrameIndex = doc["fIndex"].GetUint64();
|
||||
currentFileIndex = doc["fileIndex"].GetUint64();
|
||||
currentSubFrameIndex = doc["expLength"].GetUint();
|
||||
coordX = doc["xCoord"].GetUint();
|
||||
coordY = doc["yCoord"].GetUint();
|
||||
coordY = doc["row"].GetUint();
|
||||
coordX = doc["column"].GetUint();
|
||||
if (eiger)
|
||||
coordY = (nY - 1) - coordY;
|
||||
//cout << "X:" << doc["xCoord"].GetUint() <<" Y:"<<doc["yCoord"].GetUint();
|
||||
//cout << "X:" << doc["row"].GetUint() <<" Y:"<<doc["column"].GetUint();
|
||||
flippedDataX = doc["flippedDataX"].GetUint();
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE, "(Debug) Header Info:\n"
|
||||
@ -5375,7 +5375,7 @@ int multiSlsDetector::setReceiverSilentMode(int i) {
|
||||
return callDetectorMember(&slsDetector::setReceiverSilentMode, i);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setCTBPattern(string fname) {
|
||||
int multiSlsDetector::setCTBPattern(std::string fname) {
|
||||
uint64_t word;
|
||||
int addr = 0;
|
||||
FILE* fd = fopen(fname.c_str(), "r");
|
||||
|
@ -491,7 +491,7 @@ public:
|
||||
* @param pos position in the multi list
|
||||
* @returns slsDetector object
|
||||
*/
|
||||
slsDetector *operator()(int pos);
|
||||
slsDetector *operator()(int pos) const;
|
||||
|
||||
/**
|
||||
* Free shared memory from the command line
|
||||
|
@ -19,7 +19,7 @@ class multiSlsDetectorClient {
|
||||
|
||||
public:
|
||||
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \
|
||||
string answer; \
|
||||
std::string answer; \
|
||||
multiSlsDetectorCommand *myCmd; \
|
||||
int id = -1, pos = -1, iv = 0; \
|
||||
bool verify = true, update = true; \
|
||||
@ -90,7 +90,7 @@ public:
|
||||
strcpy(cmd, argv[0]); \
|
||||
} \
|
||||
// special commands
|
||||
string scmd = cmd; \
|
||||
std::string scmd = cmd; \
|
||||
// free without calling multiSlsDetector constructor
|
||||
if (scmd == "free") { \
|
||||
if (pos != -1) \
|
||||
|
@ -28,8 +28,8 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
|
||||
/* \returns answer string */
|
||||
/* *\/ */
|
||||
|
||||
string executeLine(int narg, char *args[], int action, int id=-1) { \
|
||||
string s; \
|
||||
std::string executeLine(int narg, char *args[], int action, int id=-1) { \
|
||||
std::string s; \
|
||||
if (id>=0) {
|
||||
slsDetector *d=myDet->getSlsDetector(id); \
|
||||
if (d) { \
|
||||
@ -39,7 +39,7 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
|
||||
myDet->setErrorMask((myDet->getErrorMask())|(1<<id)); \
|
||||
delete cmd;
|
||||
} else
|
||||
s=string("detector does no exist"); \
|
||||
s=std::string("detector does no exist"); \
|
||||
} else \
|
||||
s=slsDetectorCommand::executeLine(narg,args,action); \
|
||||
return s;
|
||||
@ -48,13 +48,13 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
|
||||
/**
|
||||
* calls executeLine with PUT_ACTION
|
||||
*/
|
||||
string putCommand(int narg, char *args[], int pos=-1){\
|
||||
std::string putCommand(int narg, char *args[], int pos=-1){\
|
||||
return executeLine(narg, args,slsDetectorDefs::PUT_ACTION,pos);\
|
||||
};
|
||||
/**
|
||||
* calls executeLine with GET_ACTION
|
||||
*/
|
||||
string getCommand(int narg, char *args[], int pos=-1){\
|
||||
std::string getCommand(int narg, char *args[], int pos=-1){\
|
||||
return executeLine(narg, args,slsDetectorDefs::GET_ACTION,pos);\
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2"
|
||||
#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3941
|
||||
#define GITDATE 0x20180718
|
||||
#define GITBRANCH "3.3.0-rc"
|
||||
#define GITREV 0x4020
|
||||
#define GITDATE 0x20180927
|
||||
#define GITBRANCH "4.0.0"
|
||||
|
@ -768,7 +768,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
thisDetector->nOffset = detlist.nOffset;
|
||||
thisDetector->dynamicRange = detlist.dynamicRange;
|
||||
thisDetector->moveFlag = detlist.moveFlag;
|
||||
detlist.nGappixelsY = detlist.nGappixelsX;
|
||||
thisDetector->nGappixels[X] = detlist.nGappixelsX;
|
||||
thisDetector->nGappixels[Y] = detlist.nGappixelsY;
|
||||
|
||||
|
||||
@ -3808,7 +3808,7 @@ int* slsDetector::getDataFromDetector(int *retval) {
|
||||
|
||||
int nodatadetectortype = false;
|
||||
detectorType types = getDetectorsType();
|
||||
if(types == EIGER || types == JUNGFRAU){
|
||||
if(types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX){
|
||||
nodatadetectortype = true;
|
||||
}
|
||||
|
||||
@ -3949,7 +3949,7 @@ int slsDetector::readAllNoWait() {
|
||||
int slsDetector::configureMAC() {
|
||||
int i;
|
||||
int ret=FAIL;
|
||||
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
|
||||
int fnum=F_CONFIGURE_MAC;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
char arg[6][50];memset(arg,0,sizeof(char)*6*50);
|
||||
int retval=-1;
|
||||
@ -4149,27 +4149,6 @@ int slsDetector::configureMAC() {
|
||||
std::cout<< "Configuring MAC failed " << std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
else if (thisDetector->myDetectorType==GOTTHARD){
|
||||
//set frames per file - only for gotthard
|
||||
pthread_mutex_lock(&ms);
|
||||
if(retval==-1)
|
||||
setFramesPerFile(MAX_FRAMES_PER_FILE);
|
||||
else
|
||||
setFramesPerFile(SHORT_MAX_FRAMES_PER_FILE);
|
||||
pthread_mutex_unlock(&ms);
|
||||
//connect to receiver
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending adc val to receiver " << retval << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -5321,6 +5300,9 @@ string slsDetector::setReceiver(string receiverIP) {
|
||||
setReceiverStreamingIP(getReceiverStreamingIP());
|
||||
setAdditionalJsonHeader(getAdditionalJsonHeader());
|
||||
enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1));
|
||||
|
||||
if(thisDetector->myDetectorType == GOTTHARD)
|
||||
sendROI(-1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6065,9 +6047,6 @@ int slsDetector::setROI(int n,ROI roiLimits[]) {
|
||||
}
|
||||
|
||||
ret = sendROI(n,roiLimits);
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
||||
|
||||
|
||||
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
|
||||
return ret;
|
||||
@ -6132,17 +6111,39 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) {
|
||||
}
|
||||
|
||||
//update client
|
||||
if(ret!=FAIL){
|
||||
if(ret==FAIL){
|
||||
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
||||
} else {
|
||||
for(int i=0;i<retvalsize;++i)
|
||||
thisDetector->roiLimits[i]=retval[i];
|
||||
thisDetector->nROI = retvalsize;
|
||||
}
|
||||
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
for(int j=0;j<thisDetector->nROI;++j)
|
||||
cout<<"get"<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"
|
||||
<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl;
|
||||
//#endif
|
||||
cout<<"ROI [" <<j<<"] ("<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"
|
||||
<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<")"<<endl;
|
||||
#endif
|
||||
|
||||
// old firmware requires configuremac after setting roi
|
||||
if (thisDetector->myDetectorType == GOTTHARD) {
|
||||
configureMAC();
|
||||
}
|
||||
|
||||
// update roi in receiver
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
int fnum=F_RECEIVER_SET_ROI;
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendROI(fnum, thisDetector->nROI, thisDetector->roiLimits);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -9026,13 +9027,6 @@ int slsDetector::startReceiver() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// tell detector to send to receiver (if start receiver failed, this is not executed)
|
||||
if(((thisDetector->myDetectorType == GOTTHARD ||
|
||||
thisDetector->myDetectorType == PROPIX) && ret!= FAIL))
|
||||
return prepareAcquisition(); // send data to receiver for these detectors
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -9044,11 +9038,6 @@ int slsDetector::stopReceiver() {
|
||||
int ret = FAIL;
|
||||
char mess[MAX_STR_LENGTH] = "";
|
||||
|
||||
if(thisDetector->myDetectorType == GOTTHARD ||
|
||||
thisDetector->myDetectorType == PROPIX)
|
||||
cleanupAcquisition(); // reset (send data to receiver) for these detectors,
|
||||
//so back to CPU (dont care about ok/fail at this point)
|
||||
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Stopping Receiver " << std::endl;
|
||||
|
@ -519,7 +519,7 @@ public:
|
||||
* @param pos insignificant
|
||||
* @returns hostname
|
||||
*/
|
||||
string getHostname(int pos = -1);
|
||||
std::string getHostname(int pos = -1);
|
||||
|
||||
/**
|
||||
* Appends detectors to the end of the list in shared memory
|
||||
@ -582,7 +582,7 @@ public:
|
||||
* @param type string of detector type
|
||||
* @returns detector type in receiver
|
||||
*/
|
||||
int setDetectorType(string stype);
|
||||
int setDetectorType(std::string stype);
|
||||
|
||||
/**
|
||||
* Get Detector type from shared memory variable
|
||||
@ -596,14 +596,14 @@ public:
|
||||
* @param pos insignificant
|
||||
* @returns string version of detector type from shared memory variable
|
||||
*/
|
||||
string sgetDetectorsType(int pos=-1);
|
||||
std::string sgetDetectorsType(int pos=-1);
|
||||
|
||||
/**
|
||||
* Just to overload getDetectorType from users
|
||||
* Gets string version of detector type from shared memory variable
|
||||
* @returns gets string version of detector type from shared memory variable
|
||||
*/
|
||||
string getDetectorType();
|
||||
std::string getDetectorType();
|
||||
|
||||
/**
|
||||
* Returns number of modules from shared memory (Mythen)
|
||||
@ -768,7 +768,7 @@ public:
|
||||
* @returns empty string if it is online
|
||||
* else returns hostnameif it is offline
|
||||
*/
|
||||
string checkOnline();
|
||||
std::string checkOnline();
|
||||
|
||||
/**
|
||||
* Configure the TCP socket communciation and initializes the socket instances
|
||||
@ -778,7 +778,7 @@ public:
|
||||
* @returns OK or FAIL
|
||||
* \sa sharedSlsDetector
|
||||
*/
|
||||
int setTCPSocket(string const name="", int const control_port=-1, int const stop_port=-1);
|
||||
int setTCPSocket(std::string const name="", int const control_port=-1, int const stop_port=-1);
|
||||
|
||||
|
||||
/**
|
||||
@ -802,7 +802,7 @@ public:
|
||||
int getStopPort();
|
||||
|
||||
/**
|
||||
* Returns the receiver TCP port \sa sharedSlsDetector
|
||||
* Returns the receiver TCP port \sa sharedSlsDetector
|
||||
* @returns the receiver TCP port
|
||||
*/
|
||||
int getReceiverPort();
|
||||
@ -818,7 +818,7 @@ public:
|
||||
* Get last client IP saved on detector server
|
||||
* @returns last client IP saved on detector server
|
||||
*/
|
||||
string getLastClientIP();
|
||||
std::string getLastClientIP();
|
||||
|
||||
/**
|
||||
* Exit detector server
|
||||
@ -833,7 +833,7 @@ public:
|
||||
* @param answer is the answer from the detector
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int execCommand(string cmd, string answer);
|
||||
int execCommand(std::string cmd, std::string answer);
|
||||
|
||||
/**
|
||||
* Updates some of the shared memory receiving the data from the detector
|
||||
@ -854,14 +854,14 @@ public:
|
||||
* @param fname configuration file name
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int readConfigurationFile(string const fname);
|
||||
int readConfigurationFile(std::string const fname);
|
||||
|
||||
/**
|
||||
* Load configuration from a stream
|
||||
* @param infile stream
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int readConfigurationFile(ifstream &infile);
|
||||
int readConfigurationFile(std::ifstream &infile);
|
||||
|
||||
/**
|
||||
* Write current configuration to a file
|
||||
@ -869,7 +869,7 @@ public:
|
||||
* @param fname configuration file name
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int writeConfigurationFile(string const fname);
|
||||
int writeConfigurationFile(std::string const fname);
|
||||
|
||||
/**
|
||||
* Write current configuration to a stream
|
||||
@ -877,13 +877,13 @@ public:
|
||||
* @param id detector id
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int writeConfigurationFile(ofstream &outfile, int id=-1);
|
||||
int writeConfigurationFile(std::ofstream &outfile, int id=-1);
|
||||
|
||||
/**
|
||||
* Returns the trimfile or settings file name (Useless??)
|
||||
* @returns the trimfile or settings file name
|
||||
*/
|
||||
string getSettingsFile();
|
||||
std::string getSettingsFile();
|
||||
|
||||
/**
|
||||
* Writes a trim/settings file for module number imod,
|
||||
@ -896,7 +896,7 @@ public:
|
||||
* \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
||||
*/
|
||||
using energyConversion::writeSettingsFile;
|
||||
int writeSettingsFile(string fname, int imod, int iodelay, int tau);
|
||||
int writeSettingsFile(std::string fname, int imod, int iodelay, int tau);
|
||||
|
||||
/**
|
||||
* Get detector settings
|
||||
@ -965,7 +965,7 @@ public:
|
||||
* @param s trimbits/settings directory
|
||||
* @returns the trimbit/settings directory
|
||||
*/
|
||||
std::string setSettingsDir(string s);
|
||||
std::string setSettingsDir(std::string s);
|
||||
|
||||
/**
|
||||
* Returns the calibration files directory \sa sharedSlsDetector (Mythen)
|
||||
@ -978,7 +978,7 @@ public:
|
||||
* @param s the calibration files directory
|
||||
* @returns the calibration files directory
|
||||
*/
|
||||
std::string setCalDir(string s);
|
||||
std::string setCalDir(std::string s);
|
||||
|
||||
/**
|
||||
* Loads the modules settings/trimbits reading from a specific file
|
||||
@ -988,7 +988,7 @@ public:
|
||||
* from which will be calculated the detector index and the module index (-1 for all)
|
||||
* returns OK or FAIL
|
||||
*/
|
||||
int loadSettingsFile(string fname, int imod=-1);
|
||||
int loadSettingsFile(std::string fname, int imod=-1);
|
||||
|
||||
/**
|
||||
* Saves the modules settings/trimbits to a specific file
|
||||
@ -997,7 +997,7 @@ public:
|
||||
* @param imod module number (-1 for all)
|
||||
* returns OK or FAIL
|
||||
*/
|
||||
int saveSettingsFile(string fname, int imod=-1);
|
||||
int saveSettingsFile(std::string fname, int imod=-1);
|
||||
|
||||
/**
|
||||
* Loads the modules calibration data reading from a specific file (Mythen)
|
||||
@ -1006,7 +1006,7 @@ public:
|
||||
* @param imod module number (-1 for all)
|
||||
* returns OK or FAIL
|
||||
*/
|
||||
int loadCalibrationFile(string fname, int imod=-1);
|
||||
int loadCalibrationFile(std::string fname, int imod=-1);
|
||||
|
||||
/**
|
||||
* Saves the modules calibration data to a specific file (Mythen)
|
||||
@ -1015,7 +1015,7 @@ public:
|
||||
* @param imod module number (-1 for all)
|
||||
* returns OK or FAIL
|
||||
*/
|
||||
int saveCalibrationFile(string fname, int imod=-1);
|
||||
int saveCalibrationFile(std::string fname, int imod=-1);
|
||||
|
||||
/**
|
||||
* Sets/gets the detector in position i as master of the structure (Mythen)
|
||||
@ -1275,94 +1275,94 @@ public:
|
||||
* @param s network parameter value
|
||||
* @returns network parameter value set (from getNetworkParameter)
|
||||
*/
|
||||
string setNetworkParameter(networkParameter index, string value);
|
||||
std::string setNetworkParameter(networkParameter index, std::string value);
|
||||
|
||||
/**
|
||||
* Get network parameter
|
||||
* @param p network parameter type
|
||||
* @returns network parameter value set (from getNetworkParameter)
|
||||
*/
|
||||
string getNetworkParameter(networkParameter index);
|
||||
std::string getNetworkParameter(networkParameter index);
|
||||
|
||||
/**
|
||||
* Returns the detector MAC address\sa sharedSlsDetector
|
||||
* @returns the detector MAC address
|
||||
*/
|
||||
string getDetectorMAC();
|
||||
std::string getDetectorMAC();
|
||||
|
||||
/**
|
||||
* Returns the detector IP address\sa sharedSlsDetector
|
||||
* @returns the detector IP address
|
||||
*/
|
||||
string getDetectorIP();
|
||||
std::string getDetectorIP();
|
||||
|
||||
/**
|
||||
* Returns the receiver IP address\sa sharedSlsDetector
|
||||
* @returns the receiver IP address
|
||||
*/
|
||||
string getReceiver();
|
||||
std::string getReceiver();
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP IP address\sa sharedSlsDetector
|
||||
* @returns the receiver UDP IP address
|
||||
*/
|
||||
string getReceiverUDPIP();
|
||||
std::string getReceiverUDPIP();
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP MAC address\sa sharedSlsDetector
|
||||
* @returns the receiver UDP MAC address
|
||||
*/
|
||||
string getReceiverUDPMAC();
|
||||
std::string getReceiverUDPMAC();
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP port\sa sharedSlsDetector
|
||||
* @returns the receiver UDP port
|
||||
*/
|
||||
string getReceiverUDPPort();
|
||||
std::string getReceiverUDPPort();
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector
|
||||
* @returns the receiver UDP port 2 of same interface
|
||||
*/
|
||||
string getReceiverUDPPort2();
|
||||
std::string getReceiverUDPPort2();
|
||||
|
||||
/**
|
||||
* Returns the client zmq port \sa sharedSlsDetector
|
||||
* @returns the client zmq port
|
||||
*/
|
||||
string getClientStreamingPort();
|
||||
std::string getClientStreamingPort();
|
||||
|
||||
/**
|
||||
* Returns the receiver zmq port \sa sharedSlsDetector
|
||||
* @returns the receiver zmq port
|
||||
*/
|
||||
string getReceiverStreamingPort();
|
||||
std::string getReceiverStreamingPort();
|
||||
|
||||
/**
|
||||
* Returns the client zmq ip \sa sharedSlsDetector
|
||||
* @returns the client zmq ip, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
string getClientStreamingIP();
|
||||
std::string getClientStreamingIP();
|
||||
|
||||
/**
|
||||
* Returns the receiver zmq ip \sa sharedSlsDetector
|
||||
* @returns the receiver zmq ip, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
string getReceiverStreamingIP();
|
||||
std::string getReceiverStreamingIP();
|
||||
|
||||
/**
|
||||
* Validates the format of the detector MAC address and sets it \sa sharedSlsDetector
|
||||
* @param detectorMAC detector MAC address
|
||||
* @returns the detector MAC address
|
||||
*/
|
||||
string setDetectorMAC(string detectorMAC);
|
||||
std::string setDetectorMAC(std::string detectorMAC);
|
||||
|
||||
/**
|
||||
* Validates the format of the detector IP address and sets it \sa sharedSlsDetector
|
||||
* @param detectorIP detector IP address
|
||||
* @returns the detector IP address
|
||||
*/
|
||||
string setDetectorIP(string detectorIP);
|
||||
std::string setDetectorIP(std::string detectorIP);
|
||||
|
||||
/**
|
||||
* Validates and sets the receiver.
|
||||
@ -1371,21 +1371,21 @@ public:
|
||||
* @param receiver receiver hostname or IP address
|
||||
* @returns the receiver IP address from shared memory
|
||||
*/
|
||||
string setReceiver(string receiver);
|
||||
std::string setReceiver(std::string receiver);
|
||||
|
||||
/**
|
||||
* Validates the format of the receiver UDP IP address and sets it \sa sharedSlsDetector
|
||||
* @param udpip receiver UDP IP address
|
||||
* @returns the receiver UDP IP address
|
||||
*/
|
||||
string setReceiverUDPIP(string udpip);
|
||||
std::string setReceiverUDPIP(std::string udpip);
|
||||
|
||||
/**
|
||||
* Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector
|
||||
* @param udpmac receiver UDP MAC address
|
||||
* @returns the receiver UDP MAC address
|
||||
*/
|
||||
string setReceiverUDPMAC(string udpmac);
|
||||
std::string setReceiverUDPMAC(std::string udpmac);
|
||||
|
||||
/**
|
||||
* Sets the receiver UDP port\sa sharedSlsDetector
|
||||
@ -1407,7 +1407,7 @@ public:
|
||||
* calculate individual ports)
|
||||
* @returns the client zmq port
|
||||
*/
|
||||
string setClientStreamingPort(string port);
|
||||
std::string setClientStreamingPort(std::string port);
|
||||
|
||||
/**
|
||||
* Sets the receiver zmq port\sa sharedSlsDetector
|
||||
@ -1415,21 +1415,21 @@ public:
|
||||
* calculate individual ports)
|
||||
* @returns the receiver zmq port
|
||||
*/
|
||||
string setReceiverStreamingPort(string port);
|
||||
std::string setReceiverStreamingPort(std::string port);
|
||||
|
||||
/**
|
||||
* Sets the client zmq ip\sa sharedSlsDetector
|
||||
* @param sourceIP client zmq ip
|
||||
* @returns the client zmq ip, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
string setClientStreamingIP(string sourceIP);
|
||||
std::string setClientStreamingIP(std::string sourceIP);
|
||||
|
||||
/**
|
||||
* Sets the receiver zmq ip\sa sharedSlsDetector
|
||||
* @param sourceIP receiver zmq ip. If empty, uses rx_hostname
|
||||
* @returns the receiver zmq ip, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
string setReceiverStreamingIP(string sourceIP);
|
||||
std::string setReceiverStreamingIP(std::string sourceIP);
|
||||
|
||||
/**
|
||||
* Execute a digital test (Gotthard, Mythen)
|
||||
@ -1455,7 +1455,7 @@ public:
|
||||
* @param fname file name from which to load image
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int loadImageToDetector(imageType index,string const fname);
|
||||
int loadImageToDetector(imageType index,std::string const fname);
|
||||
|
||||
/**
|
||||
* Called from loadImageToDetector to send the image to detector
|
||||
@ -1471,7 +1471,7 @@ public:
|
||||
* @param startACQ is 1 to start acquisition after reading counter
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int writeCounterBlockFile(string const fname,int startACQ=0);
|
||||
int writeCounterBlockFile(std::string const fname,int startACQ=0);
|
||||
|
||||
/**
|
||||
* Gets counter memory block in detector (Gotthard)
|
||||
@ -1658,7 +1658,7 @@ public:
|
||||
* @param fname file name
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int programFPGA(string fname);
|
||||
int programFPGA(std::string fname);
|
||||
|
||||
/**
|
||||
* Resets FPGA (Jungfrau)
|
||||
@ -1845,7 +1845,7 @@ public:
|
||||
* @param fname name of the flat field file (or "" if disable)
|
||||
* @returns 0 if disable (or file could not be read), >0 otherwise
|
||||
*/
|
||||
int setFlatFieldCorrection(string fname="");
|
||||
int setFlatFieldCorrection(std::string fname="");
|
||||
|
||||
/**
|
||||
* Set flat field corrections (Mythen)
|
||||
@ -1880,7 +1880,7 @@ public:
|
||||
* @param fname file with bad channel list ("" disable)
|
||||
* @returns 0 if bad channel disabled, >0 otherwise
|
||||
*/
|
||||
int setBadChannelCorrection(string fname="");
|
||||
int setBadChannelCorrection(std::string fname="");
|
||||
|
||||
/**
|
||||
* Set bad channels correction (Mythen)
|
||||
@ -1905,7 +1905,7 @@ public:
|
||||
* @param fname file to be read
|
||||
* @returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
int readAngularConversionFile(string fname="");
|
||||
int readAngularConversionFile(std::string fname="");
|
||||
|
||||
/**
|
||||
* Reads an angular conversion file (Mythen, Gotthard)
|
||||
@ -1913,7 +1913,7 @@ public:
|
||||
* @param ifs input stream
|
||||
* @returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
int readAngularConversion(ifstream& ifs);
|
||||
int readAngularConversion(std::ifstream& ifs);
|
||||
|
||||
/**
|
||||
* Writes an angular conversion file (Mythen, Gotthard)
|
||||
@ -1921,7 +1921,7 @@ public:
|
||||
* @param fname file to be written
|
||||
* @returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
int writeAngularConversion(string fname="");
|
||||
int writeAngularConversion(std::string fname="");
|
||||
|
||||
/**
|
||||
* Writes an angular conversion file (Mythen, Gotthard)
|
||||
@ -1929,7 +1929,7 @@ public:
|
||||
* @param ofs output stream
|
||||
* @returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
int writeAngularConversion(ofstream &ofs);
|
||||
int writeAngularConversion(std::ofstream &ofs);
|
||||
|
||||
/**
|
||||
* Get angular conversion (Mythen, Gotthard)
|
||||
@ -1965,7 +1965,7 @@ public:
|
||||
* Checks if the receiver is really online
|
||||
* @returns empty string if online, else returns receiver hostname
|
||||
*/
|
||||
string checkReceiverOnline();
|
||||
std::string checkReceiverOnline();
|
||||
|
||||
/**
|
||||
* Configure the socket communication and initializes the socket instances
|
||||
@ -1974,7 +1974,7 @@ public:
|
||||
* @returns OK is connection succeded, FAIL otherwise
|
||||
* \sa sharedSlsDetector
|
||||
*/
|
||||
int setReceiverTCPSocket(string const name="", int const receiver_port=-1);
|
||||
int setReceiverTCPSocket(std::string const name="", int const receiver_port=-1);
|
||||
|
||||
/**
|
||||
* Locks/Unlocks the connection to the receiver
|
||||
@ -1987,7 +1987,7 @@ public:
|
||||
* Returns the IP of the last client connecting to the receiver
|
||||
* @returns the IP of the last client connecting to the receiver
|
||||
*/
|
||||
string getReceiverLastClientIP();
|
||||
std::string getReceiverLastClientIP();
|
||||
|
||||
/**
|
||||
* Exits the receiver TCP server
|
||||
@ -2028,27 +2028,27 @@ public:
|
||||
* Returns output file directory
|
||||
* @returns output file directory
|
||||
*/
|
||||
string getFilePath();
|
||||
std::string getFilePath();
|
||||
|
||||
/**
|
||||
* Sets up the file directory
|
||||
* @param s file directory
|
||||
* @returns file dir
|
||||
*/
|
||||
string setFilePath(string s="");
|
||||
std::string setFilePath(std::string s="");
|
||||
|
||||
/**
|
||||
* Returns file name prefix
|
||||
* @returns file name prefix
|
||||
*/
|
||||
string getFileName();
|
||||
std::string getFileName();
|
||||
|
||||
/**
|
||||
* Sets up the file name prefix
|
||||
* @param s file name prefix
|
||||
* @returns file name prefix
|
||||
*/
|
||||
string setFileName(string s="");
|
||||
std::string setFileName(std::string s="");
|
||||
|
||||
/**
|
||||
* Sets the max frames per file in receiver
|
||||
@ -2236,7 +2236,7 @@ public:
|
||||
* @param fname pattern file to open
|
||||
* @returns OK/FAIL
|
||||
*/
|
||||
int setCTBPattern(string fname);
|
||||
int setCTBPattern(std::string fname);
|
||||
|
||||
/**
|
||||
* Writes a pattern word to the CTB
|
||||
@ -2394,33 +2394,33 @@ private:
|
||||
* Returns the additional json header \sa sharedSlsDetector
|
||||
* @returns the additional json header, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
string getAdditionalJsonHeader();
|
||||
std::string getAdditionalJsonHeader();
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP socket buffer size\sa sharedSlsDetector
|
||||
* @returns the receiver UDP socket buffer size
|
||||
*/
|
||||
string getReceiverUDPSocketBufferSize() ;
|
||||
std::string getReceiverUDPSocketBufferSize() ;
|
||||
|
||||
/**
|
||||
* Returns the receiver real UDP socket buffer size\sa sharedSlsDetector
|
||||
* @returns the receiver real UDP socket buffer size
|
||||
*/
|
||||
string getReceiverRealUDPSocketBufferSize();
|
||||
std::string getReceiverRealUDPSocketBufferSize();
|
||||
|
||||
/**
|
||||
* Sets the additional json header\sa sharedSlsDetector
|
||||
* @param jsonheader additional json header
|
||||
* @returns additional json header, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
string setAdditionalJsonHeader(string jsonheader);
|
||||
std::string setAdditionalJsonHeader(std::string jsonheader);
|
||||
|
||||
/**
|
||||
* Sets the receiver UDP socket buffer size
|
||||
* @param udpsockbufsize additional json header
|
||||
* @returns receiver udp socket buffer size
|
||||
*/
|
||||
string setReceiverUDPSocketBufferSize(int udpsockbufsize=-1);
|
||||
std::string setReceiverUDPSocketBufferSize(int udpsockbufsize=-1);
|
||||
|
||||
/**
|
||||
* Sets the transmission delay for left, right or entire frame
|
||||
@ -2429,7 +2429,7 @@ private:
|
||||
* @param delay delay
|
||||
* @returns transmission delay
|
||||
*/
|
||||
string setDetectorNetworkParameter(networkParameter index, int delay);
|
||||
std::string setDetectorNetworkParameter(networkParameter index, int delay);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -4464,6 +4464,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
if (cmd == "roi")
|
||||
myDet->setReceiverOnline(ONLINE_FLAG);
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
if (cmd=="maxmod")
|
||||
return string("cannot put!");
|
||||
@ -4481,10 +4484,10 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
|
||||
ROI allroi[val];
|
||||
pos=2;
|
||||
for(i=0;i<val;++i){
|
||||
if ((!sscanf(args[++pos],"%d",&allroi[i].xmin)) ||
|
||||
(!sscanf(args[++pos],"%d",&allroi[i].xmax)) ||
|
||||
(!sscanf(args[++pos],"%d",&allroi[i].ymin)) ||
|
||||
(!sscanf(args[++pos],"%d",&allroi[i].ymax)) )
|
||||
if ((!sscanf(args[pos++],"%d",&allroi[i].xmin)) ||
|
||||
(!sscanf(args[pos++],"%d",&allroi[i].xmax)) ||
|
||||
(!sscanf(args[pos++],"%d",&allroi[i].ymin)) ||
|
||||
(!sscanf(args[pos++],"%d",&allroi[i].ymax)) )
|
||||
return string("cannot parse arguments for roi");
|
||||
}
|
||||
myDet->setROI(val,allroi);
|
||||
|
@ -197,3 +197,21 @@ int receiverInterface::executeFunction(int fnum,char mess[]){
|
||||
}
|
||||
|
||||
|
||||
|
||||
int receiverInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) {
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
char mess[MAX_STR_LENGTH];
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(&n,sizeof(n));
|
||||
dataSocket->SendDataOnly(roiLimits,n * sizeof(slsReceiverDefs::ROI));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,6 +131,15 @@ public:
|
||||
*/
|
||||
int executeFunction(int fnum,char mess[]);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param n number of ROIs to send
|
||||
* @param roiLimits ROI structure
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]);
|
||||
|
||||
//here one should implement the funcs listed in
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user