after merging with developer

This commit is contained in:
2018-11-02 10:48:06 +01:00
134 changed files with 4245 additions and 4058 deletions

View File

@ -59,7 +59,6 @@ set(PUBLICHEADERS
commonFiles/sls_detector_defs.h
commonFiles/sls_detector_funcs.h
commonFiles/error_defs.h
commonFiles/sls_detector_exceptions.h
commonFiles/versionAPI.h
sharedMemory/SharedMemory.h
slsDetector/slsDetectorUtils.h
@ -78,7 +77,7 @@ set(PUBLICHEADERS
slsDetectorAnalysis/fileIOStatic.h
multiSlsDetector/multiSlsDetector.h
slsReceiverInterface/receiverInterface.h
../slsReceiverSoftware/include/sls_receiver_exceptions.h
)
set_target_properties(slsDetectorShared PROPERTIES
LIBRARY_OUTPUT_NAME SlsDetector

View File

@ -17,7 +17,7 @@ LIBZMQDIR = ../slsReceiverSoftware/include
LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq
SRC_CLNT=slsDetectorAnalysis/fileIO.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp #../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp
DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/fileIOStatic.h slsDetectorAnalysis/movingStat.h slsDetectorAnalysis/runningStat.h slsDetectorAnalysis/single_photon_hit.h threadFiles/Global.h threadFiles/Task.h usersFunctions/angleFunction.h sharedMemory/SharedMemory.h commonFiles/sls_detector_exceptions.h commonFiles/versionAPI.h
DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/fileIOStatic.h slsDetectorAnalysis/movingStat.h slsDetectorAnalysis/runningStat.h slsDetectorAnalysis/single_photon_hit.h threadFiles/Global.h threadFiles/Task.h usersFunctions/angleFunction.h sharedMemory/SharedMemory.h $(LIBZMQDIR)/sls_receiver_exceptions.h commonFiles/versionAPI.h

View File

@ -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 */
/* *\/ */

View File

@ -1,25 +0,0 @@
#pragma once
/************************************************
* @file sls_detector_exceptions.h
* @short exceptions defined
***********************************************/
/**
*@short exceptions defined
*/
#include <iostream>
#include <exception>
using namespace std;
struct SharedMemoryException : public exception {
public:
SharedMemoryException() {}
string GetMessage() const { return "Shared Memory Failed";};
};
struct ThreadpoolException : public exception {
public:
ThreadpoolException() {}
string GetMessage() const { return "Threadpool Failed";};
};

View File

@ -121,6 +121,8 @@ enum detFuncs{
F_STORAGE_CELL_START, /** < storage cell start */
F_CHECK_VERSION, /** < check version compatibility */
F_SOFTWARE_TRIGGER, /** < software trigger */
/* Always append functions hereafter!!! */
/* Always append functions before!!! */

View File

@ -1,5 +1,6 @@
/** API versions */
#define APIRECEIVER 0x180517
#define APIEIGER 0x180528
#define APIJUNGFRAU 0x180628
#define APIGOTTHARD 0x180529
#define APIRECEIVER 0x180927
#define APIEIGER 0x180820
#define APIJUNGFRAU 0x180925
#define APIGOTTHARD 0x180928

View File

@ -1215,8 +1215,10 @@ void Beb_SetDetectorNumber(uint32_t detid) {
int Beb_SetDetectorPosition(int pos[]) {
if(!Beb_activated)
return OK;
cprintf(BLUE,"Got Position values %d %d %d...\n", pos[0],pos[1], pos[2]);
pos[1] = Beb_swap_uint16(pos[1]);
pos[0] = Beb_swap_uint16(pos[0]);
//pos[1] = Beb_swap_uint16(pos[1]);
pos[2] = Beb_swap_uint16(pos[2]);
int ret = FAIL;
@ -1231,37 +1233,37 @@ int Beb_SetDetectorPosition(int pos[]) {
uint32_t value = 0;
ret = OK;
// x left
int posval = Beb_swap_uint16((Beb_top ? pos[0] : (pos[0]+1)));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
ret = FAIL;
// x right
posval = Beb_swap_uint16((Beb_top ? (pos[0]+1) : pos[0]));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
ret = FAIL;
// y left
// y left (column)
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1));
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
// y right
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]);
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
@ -1290,8 +1292,8 @@ int Beb_SetDetectorPosition(int pos[]) {
cprintf(BLUE, "Position set to...\n"
"Left: [%d, %d, %d]\n"
"Right:[%d, %d, %d]\n",
(Beb_top ? pos[0] : (pos[0]+1)), Beb_swap_uint16(pos[1]), Beb_swap_uint16(pos[2]),
(Beb_top ? (pos[0]+1) : pos[0]), Beb_swap_uint16(pos[1]), Beb_swap_uint16(pos[2]));
Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1), Beb_swap_uint16(pos[2]),
Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1], Beb_swap_uint16(pos[2]));
}
return ret;

View File

@ -37,6 +37,7 @@ unsigned int Feb_Control_acquireNReadoutMode; //safe or parallel, half or full s
unsigned int Feb_Control_triggerMode; //internal timer, external start, external window, signal polarity (external trigger and enable)
unsigned int Feb_Control_externalEnableMode; //external enabling engaged and it's polarity
unsigned int Feb_Control_subFrameMode;
unsigned int Feb_Control_softwareTrigger;
unsigned int Feb_Control_nimages;
@ -1958,6 +1959,56 @@ int Feb_Control_GetRightFPGATemp(){
return (int)temperature;
}
int64_t Feb_Control_GetMeasuredPeriod() {
unsigned int sub_num = (Module_TopAddressIsValid(&modules[1])) ?
Module_GetTopLeftAddress (&modules[1]):
Module_GetBottomLeftAddress (&modules[1]);
unsigned int value = 0;
Feb_Interface_ReadRegister(sub_num,MEAS_PERIOD_REG, &value);
return value*10;
}
int64_t Feb_Control_GetSubMeasuredPeriod() {
unsigned int sub_num = (Module_TopAddressIsValid(&modules[1])) ?
Module_GetTopLeftAddress (&modules[1]):
Module_GetBottomLeftAddress (&modules[1]);
unsigned int value = 0;
Feb_Interface_ReadRegister(sub_num,MEAS_SUBPERIOD_REG, &value);
return value*10;
}
int Feb_Control_SoftwareTrigger() {
unsigned int orig_value = 0;
Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS, &orig_value);
unsigned int cmd = orig_value | DAQ_REG_CHIP_CMDS_INT_TRIGGER;
if(Feb_Control_activated) {
// set trigger bit
#ifdef VERBOSE
cprintf(BLUE,"Setting Trigger, Register:0x%x\n",cmd);
#endif
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,cmd,0,0)) {
cprintf(RED,"Warning: Could not give software trigger\n");
return 0;
}
// unset trigger bit
#ifdef VERBOSE
cprintf(BLUE,"Unsetting Trigger, Register:0x%x\n",orig_value);
#endif
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,orig_value,0,0)) {
cprintf(RED,"Warning: Could not give software trigger\n");
return 0;
}
cprintf(BLUE,"Software Internal Trigger Sent!\n");
}
return 1;
}
uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
uint32_t value=0;

View File

@ -200,6 +200,11 @@ int Feb_Control_GetModuleNumber();
int Feb_Control_GetLeftFPGATemp();
int Feb_Control_GetRightFPGATemp();
int64_t Feb_Control_GetMeasuredPeriod();
int64_t Feb_Control_GetSubMeasuredPeriod();
int Feb_Control_SoftwareTrigger();
uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
uint32_t Feb_Control_ReadRegister(uint32_t offset);
#endif

View File

@ -22,10 +22,10 @@
#define DAQ_REG_RO_OFFSET 12
#define DAQ_REG_STATUS (0 + DAQ_REG_RO_OFFSET) //also pg and fifo status register
//temp so far
#define FEB_REG_STATUS (3 + DAQ_REG_RO_OFFSET)
#define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) //also pg and fifo status register
#define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3)
#define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4)
#define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5)
@ -64,7 +64,8 @@
#define DAQ_CHIP_CONTROLLER_QUARTER_SPEED 0x00080000 //everything at 50 MHz (25MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED 0x000c0000 //everything at ~200 kHz (200 kHz MHz ddr readout)
#define DAQ_FIFO_ENABLE 0x00100000
//#define DAQ_FIFO_ENABLE 0x00100000 commented out as it is not used anywhere
#define DAQ_REG_CHIP_CMDS_INT_TRIGGER 0x00100000
//direct chip commands to the DAQ_REG_CHIP_CMDS register
#define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE 0x00200000 //row clk is before main clk readout sequence

View File

@ -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: 3b6ead77836f2b6d2a795a9a994259d1dc8c131d
Revision: 343
Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
Revision: 350
Branch: developer
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3943
Last Changed Date: 2018-07-17 16:15:43.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

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "3b6ead77836f2b6d2a795a9a994259d1dc8c131d"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3943
#define GITDATE 0x20180717
#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
#define GITAUTH "Gemma_Tinti"
#define GITREV 0x3999
#define GITDATE 0x20180928
#define GITBRANCH "developer"

View File

@ -458,7 +458,7 @@ void setupDetector() {
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
setTimer(SUBFRAME_ACQUISITION_TIME, DEFAULT_SUBFRAME_EXPOSURE);
setTimer(SUBFRAME_PERIOD, DEFAULT_SUBFRAME_PERIOD);
setTimer(SUBFRAME_DEADTIME, DEFAULT_SUBFRAME_DEADTIME);
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
@ -657,6 +657,10 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val){
/* parameters - timer */
int64_t setTimer(enum timerIndex ind, int64_t val){
#ifndef VIRTUAL
int64_t subdeadtime = 0;
#endif
int64_t subexptime = 0;
switch(ind){
case FRAME_NUMBER:
if(val >= 0){
@ -694,11 +698,20 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
case SUBFRAME_ACQUISITION_TIME:
if(val >= 0){
printf(" Setting sub exp time: %lldns\n",(long long int)val/10);
printf(" Setting sub exp time: %lldns\n",(long long int)val);
#ifndef VIRTUAL
// calculate subdeadtime before settings subexptime
subdeadtime = Feb_Control_GetSubFramePeriod() -
Feb_Control_GetSubFrameExposureTime();
Feb_Control_SetSubFrameExposureTime(val/10);
// set subperiod
Feb_Control_SetSubFramePeriod((val+subdeadtime)/10);
#else
int64_t subdeadtime = eiger_virtual_subperiod*10 -
eiger_virtual_subexptime*10;
eiger_virtual_subexptime = (val/(10));
eiger_virtual_subperiod = (val+subdeadtime/10);
#endif
}
#ifndef VIRTUAL
@ -707,19 +720,30 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
return eiger_virtual_subexptime*10;
#endif
case SUBFRAME_PERIOD:
case SUBFRAME_DEADTIME:
#ifndef VIRTUAL
// get subexptime
subexptime = Feb_Control_GetSubFrameExposureTime();
#else
subexptime = eiger_virtual_subexptime*10;
#endif
if(val >= 0){
printf(" Setting sub period: %lldns\n",(long long int)val/10);
printf(" Setting sub period: %lldns = subexptime(%lld) + subdeadtime(%lld)\n",
(long long int)(val + subexptime),
(long long int)subexptime,
(long long int)val);
//calculate subperiod
val += subexptime;
#ifndef VIRTUAL
Feb_Control_SetSubFramePeriod(val/10);
#else
eiger_virtual_subperiod = (val/(1E9));
eiger_virtual_subperiod = (val/10);
#endif
}
#ifndef VIRTUAL
return (Feb_Control_GetSubFramePeriod());
return (Feb_Control_GetSubFramePeriod() - subexptime);
#else
return eiger_virtual_subperiod*1e9;
return (eiger_virtual_subperiod*10 - subexptime);
#endif
case FRAME_PERIOD:
@ -764,6 +788,21 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
}
int64_t getTimeLeft(enum timerIndex ind) {
#ifdef VIRTUAL
return 0;
#else
switch(ind){
case MEASURED_PERIOD: return Feb_Control_GetMeasuredPeriod();
case MEASURED_SUBPERIOD: return Feb_Control_GetSubMeasuredPeriod();
return 0;
default:
cprintf(RED,"This timer left index (%d) not defined for Eiger\n",ind);
return -1;
}
#endif
}
@ -1579,6 +1618,16 @@ int stopStateMachine(){
#endif
}
int softwareTrigger() {
#ifdef VIRTUAL
return OK;
#else
if (!Feb_Control_SoftwareTrigger())
return FAIL;
return OK;
#endif
}
int startReadOut(){

View File

@ -12,7 +12,7 @@
#include <stdint.h>
#define GOODBYE (-200)
#define REQUIRED_FIRMWARE_VERSION (21)
#define REQUIRED_FIRMWARE_VERSION (22)
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
#define STATUS_IDLE 0
@ -74,7 +74,7 @@ enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_SUBFRAME_EXPOSURE (2621440) // 2.6ms
#define DEFAULT_SUBFRAME_PERIOD (0)
#define DEFAULT_SUBFRAME_DEADTIME (0)
#define DEFAULT_DYNAMIC_RANGE (16)
#define DEFAULT_READOUT_MODE (NONPARALLEL)

View File

@ -1,9 +1,18 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
<<<<<<< HEAD
Repsitory UUID: 83600fcb15c8261173ab15a8ba8d1009693f2d23
Revision: 2005
Branch: anna
Last Changed Author: Anna_Bergamaschi
Last Changed Rev: 3962
Last Changed Date: 2018-09-11 16:29:59.000000002 +0200 ./slsDetector/slsDetector.o
=======
Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
Revision: 2040
Branch: 4.0.0
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4020
Last Changed Date: 2018-09-27 18:22:10.000000002 +0200 ./sharedMemory/SharedMemory.o
>>>>>>> developer

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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;
}

View File

@ -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();

View File

@ -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: 711e0d771edb48e77fa23d965f026add268a31ee
Revision: 235
Branch: 3.3.0-rc
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3944
Last Changed Date: 2018-07-26 13:38:23.000000002 +0200 ./server_defs.h
Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
Revision: 237
Branch: developer
Last Changed Author: Gemma_Tinti
Last Changed Rev: 3999
Last Changed Date: 2018-09-28 16:10:41.000000002 +0200 ./server_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "711e0d771edb48e77fa23d965f026add268a31ee"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3944
#define GITDATE 0x20180726
#define GITBRANCH "3.3.0-rc"
#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
#define GITAUTH "Gemma_Tinti"
#define GITREV 0x3999
#define GITDATE 0x20180928
#define GITBRANCH "developer"

View File

@ -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;

View File

@ -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

View File

@ -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*/

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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: 3b6ead77836f2b6d2a795a9a994259d1dc8c131d
Revision: 159
Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
Revision: 163
Branch: developer
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3943
Last Changed Date: 2018-07-17 16:15:43.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

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "3b6ead77836f2b6d2a795a9a994259d1dc8c131d"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3943
#define GITDATE 0x20180717
#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
#define GITAUTH "Gemma_Tinti"
#define GITREV 0x3999
#define GITDATE 0x20180928
#define GITBRANCH "developer"

View File

@ -10,7 +10,7 @@
#define GOODBYE (-200)
#define PROGRAMMING_MODE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWR_VRSN 0x180226
#define REQRD_FRMWR_VRSN 0x180615
/* Struct Definitions */

File diff suppressed because it is too large Load Diff

View File

@ -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
@ -945,6 +945,12 @@ public:
*/
int stopAcquisition();
/**
* Give an internal software trigger to the detector (Eiger only)
* @return OK or FAIL
*/
int sendSoftwareTrigger();
/**
* Start readout (without exposure or interrupting exposure) (Mythen)
* @returns OK or FAIL
@ -1042,9 +1048,10 @@ public:
* Set/get timer value left in acquisition (not all implemented for all detectors)
* @param index timer index
* @param t time in ns or number of...(e.g. frames, gates, probes)
* @param imod module number
* @returns timer set value in ns or number of...(e.g. frames, gates, probes)
*/
int64_t getTimeLeft(timerIndex index);
int64_t getTimeLeft(timerIndex index, int imod = -1);
/**
* Set speed
@ -1235,11 +1242,18 @@ public:
int writeAdcRegister(int addr, int val);
/**
* Activates the detector (Eiger only)
* Activates/Deactivates the detector (Eiger only)
* @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active)
* @returns 0 (inactive) or 1 (active)for activate mode
*/
int activate(int const enable=GET_ONLINE_FLAG);
int activate(int const enable=-1);
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
int setDeactivatedRxrPaddingMode(int padding=-1);
/**
* Returns the enable if data will be flipped across x or y axis (Eiger)

View File

@ -4,7 +4,7 @@
#include "multiSlsDetector.h"
#include "multiSlsDetectorCommand.h"
#include "sls_detector_exceptions.h"
#include "sls_receiver_exceptions.h"
#include <stdlib.h>
@ -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) \
@ -113,9 +113,10 @@ public:
// create multiSlsDetector class if required
if (myDetector==NULL) { \
try { \
myDetector = new multiSlsDetector(id, verify, update); \
} catch (const SharedMemoryException & e) { \
cout << e.GetMessage() << endl; \
multiSlsDetector* m = new multiSlsDetector(id, verify, update); \
myDetector = m; \
} catch (const SlsDetectorPackageExceptions & e) { \
/*cout << e.GetMessage() << endl;*/ \
return; \
} catch (...) { \
cout << " caught exception" << endl; \
@ -128,8 +129,8 @@ public:
myCmd=new multiSlsDetectorCommand(myDetector); \
try { \
answer=myCmd->executeLine(argc, argv, action, pos); \
} catch (const SharedMemoryException & e) { \
cout << e.GetMessage() << endl; \
} catch (const SlsDetectorPackageExceptions & e) { \
/*cout << e.GetMessage() << endl; */ \
delete myCmd; \
if (del) delete myDetector; \
return; \

View File

@ -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);\
};

View File

@ -1,5 +1,5 @@
#include "SharedMemory.h"
#include "sls_detector_exceptions.h"
#include "sls_receiver_exceptions.h"
#include "ansi.h"
#include <iostream>
@ -61,6 +61,7 @@ void* SharedMemory::CreateSharedMemory(size_t sz){
cprintf(RED, "Error: Create shared memory %s failed at ftruncate: %s\n",
name.c_str(), strerror(errno));
close(fd);
RemoveSharedMemory();
throw SharedMemoryException();
}
@ -122,14 +123,14 @@ void* SharedMemory::MapSharedMemory(size_t sz) {
std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) {
// using environment path
string sEnvPath = "";
std::string sEnvPath = "";
char* envpath = getenv(SHM_ENV_NAME);
if (envpath != NULL) {
sEnvPath.assign(envpath);
sEnvPath.insert(0,"_");
}
stringstream ss;
std::stringstream ss;
if (slsId < 0)
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
else
@ -137,8 +138,10 @@ std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) {
std::string temp = ss.str();
if (temp.length() > NAME_MAX) {
cprintf(RED, "Error: Shared memory initialization %s failed: %s\n",
name.c_str(), strerror(errno));
cprintf(RED, "Error: Shared memory initialization failed. "
"%s has %lu characters. \n"
"Maximum is %d. Change the environment variable %s\n",
temp.c_str(), temp.length(), NAME_MAX, SHM_ENV_NAME);
throw SharedMemoryException();
}
return temp;

View File

@ -88,24 +88,26 @@ int main(int argc, char* argv[])
int ret=slsReceiverDefs::FAIL;
int arg[2]={idx,0};
MySocketTCP* mySocket = 0;
MySocketTCP* tempSocket=new MySocketTCP(argv[1],1952);
if (tempSocket->getErrorStatus()){
try {
mySocket = new MySocketTCP(argv[1],1952);
} catch (...) {
cerr << "could not create socket with " << argv[1] << endl;
help();
}
if (tempSocket->Connect()) {
tempSocket->SendDataOnly(&fnum, sizeof(fnum));
tempSocket->SendDataOnly(arg,sizeof(arg));
tempSocket->ReceiveDataOnly(&ret, sizeof(ret));
if (mySocket->Connect()) {
mySocket->SendDataOnly(&fnum, sizeof(fnum));
mySocket->SendDataOnly(arg,sizeof(arg));
mySocket->ReceiveDataOnly(&ret, sizeof(ret));
if (ret != slsReceiverDefs::FAIL) {
tempSocket->ReceiveDataOnly(&retval, sizeof(retval));
mySocket->ReceiveDataOnly(&retval, sizeof(retval));
} else {
tempSocket->ReceiveDataOnly(mess,sizeof(mess));
mySocket->ReceiveDataOnly(mess,sizeof(mess));
printf("Detector returned Error: %s",mess);
}
tempSocket->Disconnect();
mySocket->Disconnect();
} else
cerr << "could not connect to " << argv[1] << endl;

View File

@ -1,6 +1,7 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "83600fcb15c8261173ab15a8ba8d1009693f2d23"
#define GITAUTH "Anna_Bergamaschi"
#define GITREV 0x3962
#define GITDATE 0x20180911
#define GITBRANCH "anna"
#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4020
#define GITDATE 0x20180927
#define GITBRANCH "4.0.0"

View File

@ -1,6 +1,6 @@
#include "slsDetector.h"
#include "multiSlsDetector.h"
#include "sls_detector_exceptions.h"
#include "sls_receiver_exceptions.h"
#include "SharedMemory.h"
#include "receiverInterface.h"
#include "gitInfoLib.h"
@ -53,7 +53,6 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify, mu
}
delete shm;
initSharedMemory(true, type, multiId, verify);
initializeDetectorStructure(type);
initializeMembers();
@ -81,8 +80,10 @@ slsDetector::slsDetector(int multiId, int id, bool verify, multiSlsDetector* m)
offset(0) {
/* called from multi constructor to populate structure,
* so sls shared memory will be opened, not created */
// getDetectorType Froom shm will check if it was already existing
detectorType type = getDetectorTypeFromShm(multiId, verify);
initSharedMemory(false, type, multiId, verify);
initializeMembers();
}
@ -424,41 +425,46 @@ void slsDetector::addMultipleDetectors(const char* name) {
cprintf(RED, "Error: Add Multiple Detectors should not be called at this level\n");
}
/*
* pre: sharedMemory=0, thisDetector = 0
* exceptions are caught in calling function, shm unmapped and deleted
*/
void slsDetector::initSharedMemory(bool created, detectorType type, int multiId,
bool verify) {
if (sharedMemory)
delete sharedMemory;
thisDetector = 0;
try {
// calculate shared memory size
int sz = calculateSharedMemorySize(type);
// calculate shared memory size
int sz = calculateSharedMemorySize(type);
// shared memory object with name
sharedMemory = new SharedMemory(multiId, detId);
// shared memory object with name
sharedMemory = new SharedMemory(multiId, detId);
// create
if (created) {
try {
// create
if (created) {
thisDetector = (sharedSlsDetector*)sharedMemory->CreateSharedMemory(sz);
} catch(...) {
sharedMemory->RemoveSharedMemory();
}
// open and verify version
else {
thisDetector = (sharedSlsDetector*)sharedMemory->OpenSharedMemory(sz);
if (verify && thisDetector->shmversion != SLS_SHMVERSION) {
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
"(expected 0x%x but got 0x%x)\n",
multiId, detId, SLS_SHMVERSION,
thisDetector->shmversion);
throw SharedMemoryException();
}
}
} catch(...) {
if (sharedMemory) {
// unmap
if (thisDetector) {
sharedMemory->UnmapSharedMemory(thisDetector);
thisDetector = 0;
}
// delete
delete sharedMemory;
sharedMemory = 0;
thisDetector = 0;
throw;
}
}
// open and verify version
else {
thisDetector = (sharedSlsDetector*)sharedMemory->OpenSharedMemory(sz);
if (verify && thisDetector->shmversion != SLS_SHMVERSION) {
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
"(expected 0x%x but got 0x%x)\n",
multiId, detId, SLS_SHMVERSION, thisDetector->shmversion);
sharedMemory->UnmapSharedMemory(thisDetector); /** is this unncessary? */
delete sharedMemory;/** is this unncessary? */
sharedMemory = 0;
throw SharedMemoryException();
}
throw;
}
}
@ -696,7 +702,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
thisDetector->timerValue[SAMPLES_JCTB] = 1;
thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] = 0;
thisDetector->timerValue[STORAGE_CELL_NUMBER] = 0;
thisDetector->timerValue[SUBFRAME_PERIOD] = 0;
thisDetector->timerValue[SUBFRAME_DEADTIME] = 0;
thisDetector->actionMask = 0;
for (int i = 0; i < MAX_ACTIONS; ++i) {
strcpy(thisDetector->actionScript[i], "none");
@ -743,7 +749,9 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
thisDetector->receiverAPIVersion = 0;
thisDetector->receiver_frameDiscardMode = NO_DISCARD;
thisDetector->receiver_framePadding = 1;
thisDetector->activated = true;
thisDetector->receiver_deactivatedPaddingEnable = true;
thisDetector->receiver_silentMode = false;
// get the detector parameters based on type
detParameterList detlist;
@ -760,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;
@ -1001,7 +1009,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty
nd = detlist.nDacs;
na = detlist.nAdcs;
} catch(...) {
;// FIXME do what here?
return NULL;
}
dacs_t *dacs=new dacs_t[nd];
dacs_t *adcs=new dacs_t[na];
@ -1255,35 +1263,48 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
slsReceiverDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, bool verify) {
SharedMemory* shm = new SharedMemory(multiId, detId);
// shm not created before
if (!shm->IsExisting()) {
cprintf(RED,"Shared memory %s does not exist.\n"
"Corrupted Multi Shared memory. Please free shared memory.\n",
shm->GetName().c_str());
throw SharedMemoryException();
detectorType type = GENERIC;
SharedMemory* shm = 0;
try {
// create
shm = new SharedMemory(multiId, detId);
// shm not created before
if (!shm->IsExisting()) {
cprintf(RED,"Shared memory %s does not exist.\n"
"Corrupted Multi Shared memory. Please free shared memory.\n",
shm->GetName().c_str());
throw SharedMemoryException();
}
// only basic size of structure (just version is required)
sharedSlsDetector* sdet = 0;
size_t sz = sizeof(sharedSlsDetector);
// open, map, verify version
sdet = (sharedSlsDetector*)shm->OpenSharedMemory(sz);
if (verify && sdet->shmversion != SLS_SHMVERSION) {
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
"(expected 0x%x but got 0x%x)\n",
multiId, detId, SLS_SHMVERSION, sdet->shmversion);
// unmap and throw
sharedMemory->UnmapSharedMemory(thisDetector);
throw SharedMemoryException();
}
// get type, unmap
type = sdet->myDetectorType;
shm->UnmapSharedMemory(sdet);
delete shm;
} catch (...) {
if (shm)
delete shm;
throw;
}
// map basic size of sls detector structure (no need of offsets, just version is required)
sharedSlsDetector* sdet = 0;
size_t sz = sizeof(sharedSlsDetector);
// open, map, verify version, get type
sdet = (sharedSlsDetector*)shm->OpenSharedMemory(sz);
if (verify && sdet->shmversion != SLS_SHMVERSION) {
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
"(expected 0x%x but got 0x%x)\n",
multiId, detId, SLS_SHMVERSION, sdet->shmversion);
shm->UnmapSharedMemory(sdet); /** is this unncessary? */
delete shm;/** is this unncessary? */
throw SharedMemoryException();
}
detectorType type = sdet->myDetectorType;
// unmap
shm->UnmapSharedMemory(sdet);
delete shm;
return type;
}
@ -1291,29 +1312,38 @@ slsReceiverDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b
slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) {
int fnum=F_GET_DETECTOR_TYPE;
int retval = FAIL;
detectorType t=GENERIC;
MySocketTCP *s= new MySocketTCP(name, cport);
detectorType t = GENERIC;
MySocketTCP* mySocket = 0;
try {
mySocket = new MySocketTCP(name, cport);
} catch(...) {
cout << "Cannot create socket to server " << name << " over port " << cport << endl;
return t;
}
char m[MAX_STR_LENGTH];
#ifdef VERBOSE
cout << "Getting detector type " << endl;
#endif
if (s->Connect() >= 0) {
s->SendDataOnly(&fnum,sizeof(fnum));
s->ReceiveDataOnly(&retval,sizeof(retval));
if (mySocket->Connect() >= 0) {
mySocket->SendDataOnly(&fnum,sizeof(fnum));
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
if (retval!=FAIL) {
s->ReceiveDataOnly(&t,sizeof(t));
mySocket->ReceiveDataOnly(&t,sizeof(t));
#ifdef VERBOSE
cout << "Detector type is "<< t << endl;
#endif
} else {
s->ReceiveDataOnly(m,sizeof(m));
mySocket->ReceiveDataOnly(m,sizeof(m));
std::cout<< "Detector returned error: " << m << std::endl;
}
s->Disconnect();
mySocket->Disconnect();
} else {
cout << "Cannot connect to server " << name << " over port " << cport << endl;
}
delete s;
delete mySocket;
return t;
}
@ -1749,7 +1779,7 @@ string slsDetector::checkOnline() {
controlSocket->SetTimeOut(5);
thisDetector->onlineFlag=OFFLINE_FLAG;
delete controlSocket;
controlSocket=NULL;
controlSocket=0;
retval = string(thisDetector->hostname);
#ifdef VERBOSE
std::cout<< "offline!" << std::endl;
@ -1769,7 +1799,7 @@ string slsDetector::checkOnline() {
stopSocket->SetTimeOut(5);
thisDetector->onlineFlag=OFFLINE_FLAG;
delete stopSocket;
stopSocket=NULL;
stopSocket=0;
retval = string(thisDetector->hostname);
#ifdef VERBOSE
std::cout<< "stop offline!" << std::endl;
@ -1802,11 +1832,11 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
strcpy(thisDetector->hostname,thisName);
if (controlSocket) {
delete controlSocket;
controlSocket=NULL;
controlSocket=0;
}
if (stopSocket) {
delete stopSocket;
stopSocket=NULL;
stopSocket=0;
}
} else
strcpy(thisName,thisDetector->hostname);
@ -1819,7 +1849,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
thisDetector->controlPort=thisCP;
if (controlSocket) {
delete controlSocket;
controlSocket=NULL;
controlSocket=0;
}
} else
thisCP=thisDetector->controlPort;
@ -1832,46 +1862,50 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
thisDetector->stopPort=thisSP;
if (stopSocket) {
delete stopSocket;
stopSocket=NULL;
stopSocket=0;
}
} else
thisSP=thisDetector->stopPort;
// create control socket
if (!controlSocket) {
controlSocket= new MySocketTCP(thisName, thisCP);
if (controlSocket->getErrorStatus()){
#ifdef VERBOSE
std::cout<< "Could not connect Control socket " << thisName << " "
<< thisCP << std::endl;
#endif
delete controlSocket;
controlSocket=NULL;
retval=FAIL;
}
try {
controlSocket = new MySocketTCP(thisName, thisCP);
#ifdef VERYVERBOSE
else
std::cout<< "Control socket connected " <<thisName << " " << thisCP
<< std::endl;
std::cout<< "Control socket connected " <<
thisName << " " << thisCP << std::endl;
#endif
} catch(...) {
#ifdef VERBOSE
std::cout<< "Could not connect Control socket " <<
thisName << " " << thisCP << std::endl;
#endif
controlSocket = 0;
retval = FAIL;
}
}
// create stop socket
if (!stopSocket) {
stopSocket=new MySocketTCP(thisName, thisSP);
if (stopSocket->getErrorStatus()){
#ifdef VERBOSE
std::cout<< "Could not connect Stop socket "<<thisName << " " << thisSP
<< std::endl;
#endif
delete stopSocket;
stopSocket=NULL;
retval=FAIL;
}
try {
stopSocket = new MySocketTCP(thisName, thisSP);
#ifdef VERYVERBOSE
else
std::cout<< "Stop socket connected " << thisName << " " << thisSP
<< std::endl;
std::cout<< "Stop socket connected " <<
thisName << " " << thisSP << std::endl;
#endif
} catch(...) {
#ifdef VERBOSE
std::cout<< "Could not connect Stop socket " <<
thisName << " " << thisSP << std::endl;
#endif
stopSocket = 0;
retval = FAIL;
}
}
if (retval!=FAIL) {
checkOnline();
@ -1909,7 +1943,7 @@ int slsDetector::setPort(portType index, int num) {
char mess[MAX_STR_LENGTH]="";
int ret=FAIL;
bool online=false;
MySocketTCP *s;
MySocketTCP *s = 0;
if (num>1024) {
switch(index) {
@ -1921,7 +1955,7 @@ int slsDetector::setPort(portType index, int num) {
cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort
<< endl;
#endif
if (s==NULL) {
if (s==0) {
#ifdef VERBOSE
cout << "s=NULL"<< endl;
@ -1959,7 +1993,7 @@ int slsDetector::setPort(portType index, int num) {
s=dataSocket;
retval=thisDetector->receiverTCPPort;
if(strcmp(thisDetector->receiver_hostname,"none")){
if (s==NULL) setReceiverTCPSocket("",retval);
if (s==0) setReceiverTCPSocket("",retval);
if (dataSocket)s=dataSocket;
}
online = (thisDetector->receiverOnlineFlag==ONLINE_FLAG);
@ -1979,7 +2013,7 @@ int slsDetector::setPort(portType index, int num) {
case STOP_PORT:
s=stopSocket;
retval=thisDetector->stopPort;
if (s==NULL) setTCPSocket("",-1,DEFAULT_PORTNO+1);
if (s==0) setTCPSocket("",-1,DEFAULT_PORTNO+1);
if (stopSocket) s=stopSocket;
else setTCPSocket("",-1,retval);
online = (thisDetector->onlineFlag==ONLINE_FLAG);
@ -1996,7 +2030,7 @@ int slsDetector::setPort(portType index, int num) {
break;
default:
s=NULL;
s=0;
break;
}
@ -2281,63 +2315,51 @@ int slsDetector::updateDetectorNoWait() {
n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm));
thisDetector->dataBytes=nm;
//t=setSettings(GET_SETTINGS);
n += controlSocket->ReceiveDataOnly( &t,sizeof(t));
thisDetector->currentSettings=t;
if((thisDetector->myDetectorType == EIGER) ||
(thisDetector->myDetectorType == MYTHEN)){
//thr=getThresholdEnergy();
n += controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
thisDetector->currentThresholdEV=thr;
}
//retval=setFrames(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[FRAME_NUMBER]=retval;
// retval=setExposureTime(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[ACQUISITION_TIME]=retval;
if(thisDetector->myDetectorType == EIGER){
//retval=setSubFrameExposureTime(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]=retval;
//retval=setSubFramePeriod(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[SUBFRAME_PERIOD]=retval;
thisDetector->timerValue[SUBFRAME_DEADTIME]=retval;
}
//retval=setPeriod(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[FRAME_PERIOD]=retval;
if(thisDetector->myDetectorType != EIGER) {
//retval=setDelay(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval;
}
// retval=setGates(tns);
if ((thisDetector->myDetectorType != JUNGFRAU) &&
(thisDetector->myDetectorType != EIGER)){
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[GATES_NUMBER]=retval;
}
//retval=setProbes(tns);
if (thisDetector->myDetectorType == MYTHEN){
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[PROBES_NUMBER]=retval;
}
//retval=setTrains(tns);
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[CYCLES_NUMBER]=retval;
//retval=setProbes(tns);
if (thisDetector->myDetectorType == JUNGFRAUCTB){
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
if (retval>=0)
@ -2346,10 +2368,7 @@ int slsDetector::updateDetectorNoWait() {
thisDetector->roFlags=ro;
//retval=setProbes(tns);
getTotalNumberOfChannels();
// thisDetector->dataBytes=getTotalNumberOfChannels()*
//thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
}
@ -3673,7 +3692,6 @@ int slsDetector::cleanupAcquisition() {
int slsDetector::startAcquisition() {
int fnum=F_START_ACQUISITION;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
@ -3696,9 +3714,6 @@ int slsDetector::startAcquisition() {
}
}
return ret;
}
@ -3743,6 +3758,35 @@ int slsDetector::stopAcquisition() {
}
int slsDetector::sendSoftwareTrigger() {
int fnum=F_SOFTWARE_TRIGGER;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
#ifdef VERBOSE
std::cout<< "Sending software trigger "<< std::endl;
#endif
thisDetector->stoppedFlag=0;
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return ret;
}
int slsDetector::startReadOut() {
int fnum=F_START_READOUT;
@ -3848,7 +3892,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;
}
@ -3989,7 +4033,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;
@ -4002,14 +4046,10 @@ int slsDetector::configureMAC() {
if (thisDetector->myDetectorType == JUNGFRAU ||
thisDetector->myDetectorType == EIGER) {
sendpos = true;
int max = multiDet->getNumberOfDetectors(X);
if(!detId) {
pos[0] = 0;
pos[1] = 0;
} else {
pos[1] = detId / max;
pos[0] = (detId % max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1); // for horiz. udp ports
}
int max = multiDet->getNumberOfDetectors(Y);
pos[0] = (detId % max); // row
pos[1] = (detId / max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1);// col for horiz. udp ports
}
#ifdef VERBOSE
cout << "SLS [" << detId << "] - (" << pos[0] << "," << pos[1] << "," <<
@ -4193,27 +4233,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;
}
@ -4328,7 +4347,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) {
//send acquisiton time/period/subexptime/frame/cycles/samples to receiver
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)||
(index==ACQUISITION_TIME) || (index==SUBFRAME_ACQUISITION_TIME) ||
(index==SUBFRAME_PERIOD) ||
(index==SUBFRAME_DEADTIME) ||
(index==SAMPLES_JCTB) || (index==STORAGE_CELL_NUMBER)){
string timername = getTimerType(index);
if(ret != FAIL){
@ -4379,7 +4398,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) {
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
break;
case SUBFRAME_ACQUISITION_TIME:
case SUBFRAME_PERIOD:
case SUBFRAME_DEADTIME:
case SAMPLES_JCTB:
setErrorMask((getErrorMask())|(RECEIVER_TIMER_NOT_SET));
break;
@ -4399,7 +4418,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) {
int64_t slsDetector::getTimeLeft(timerIndex index) {
int64_t slsDetector::getTimeLeft(timerIndex index, int imod) {
int fnum=F_GET_TIME_LEFT;
@ -5524,9 +5543,14 @@ string slsDetector::setReceiver(string receiverIP) {
std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl;
std::cout << "sub exp time:" << thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]
<< endl;
std::cout << "sub period:" << thisDetector->timerValue[SUBFRAME_PERIOD] << endl;
std::cout << "sub dead time:" << thisDetector->timerValue[SUBFRAME_DEADTIME] << endl;
std::cout << "dynamic range:" << thisDetector->dynamicRange << endl;
std::cout << "flippeddatax:" << thisDetector->flippedData[X] << endl;
if (thisDetector->myDetectorType == EIGER) {
std::cout << "activated: " << thisDetector->activated << endl;
std::cout << "receiver deactivated padding: " << thisDetector->receiver_deactivatedPaddingEnable << endl;
}
std::cout << "silent Mode:" << thisDetector->receiver_silentMode << endl;
std::cout << "10GbE:" << thisDetector->tenGigaEnable << endl;
std::cout << "Gap pixels: " << thisDetector->gappixels << endl;
std::cout << "rx streaming source ip:" << thisDetector->receiver_zmqip << endl;
@ -5538,8 +5562,7 @@ string slsDetector::setReceiver(string receiverIP) {
#endif
if(setDetectorType()!= GENERIC){
if(!detId)
sendMultiDetectorSize();
sendMultiDetectorSize();
setDetectorId();
setDetectorHostname();
setUDPConnection();
@ -5566,7 +5589,7 @@ string slsDetector::setReceiver(string receiverIP) {
if(thisDetector->myDetectorType == EIGER) {
setTimer(SUBFRAME_ACQUISITION_TIME,
thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]);
setTimer(SUBFRAME_PERIOD,thisDetector->timerValue[SUBFRAME_PERIOD]);
setTimer(SUBFRAME_DEADTIME,thisDetector->timerValue[SUBFRAME_DEADTIME]);
}
if(thisDetector->myDetectorType == JUNGFRAUCTB)
setTimer(SAMPLES_JCTB,thisDetector->timerValue[SAMPLES_JCTB]);
@ -5574,7 +5597,9 @@ string slsDetector::setReceiver(string receiverIP) {
if(thisDetector->myDetectorType == EIGER){
setFlippedData(X,-1);
activate(-1);
setDeactivatedRxrPaddingMode(thisDetector->receiver_deactivatedPaddingEnable);
}
setReceiverSilentMode(thisDetector->receiver_silentMode);
if(thisDetector->myDetectorType == EIGER)
enableTenGigabitEthernet(thisDetector->tenGigaEnable);
@ -5587,6 +5612,9 @@ string slsDetector::setReceiver(string receiverIP) {
setReceiverStreamingIP(getReceiverStreamingIP());
setAdditionalJsonHeader(getAdditionalJsonHeader());
enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1));
if(thisDetector->myDetectorType == GOTTHARD)
sendROI(-1, NULL);
}
}
@ -6401,6 +6429,7 @@ int slsDetector::setROI(int n,ROI roiLimits[]) {
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
return ret;
}
@ -6493,17 +6522,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;
}
@ -6561,7 +6612,7 @@ int slsDetector::activate(int const enable) {
int retval = -1;
int arg = enable;
char mess[MAX_STR_LENGTH]="";
int ret = OK;
int ret = FAIL;
if(thisDetector->myDetectorType != EIGER){
std::cout<< "Not implemented for this detector" << std::endl;
@ -6588,6 +6639,7 @@ int slsDetector::activate(int const enable) {
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
thisDetector->activated = retval;
}
disconnectControl();
if (ret==FORCE_UPDATE)
@ -6604,12 +6656,13 @@ int slsDetector::activate(int const enable) {
#endif
if(ret!=FAIL){
int arg = thisDetector->activated;
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl;
std::cout << "Activating/Deactivating Receiver: " << arg << std::endl;
#endif
if (connectData() == OK){
ret=thisReceiver->sendInt(fnum2,retval,retval);
ret=thisReceiver->sendInt(fnum2,retval,arg);
disconnectData();
}
if(ret==FAIL)
@ -6626,12 +6679,44 @@ int slsDetector::activate(int const enable) {
#endif
return retval;
return thisDetector->activated;
}
int slsDetector::setDeactivatedRxrPaddingMode(int padding) {
int fnum = F_RECEIVER_DEACTIVATED_PADDING_ENABLE;
int retval = -1;
int arg = padding;
int ret = OK;
if(thisDetector->myDetectorType != EIGER){
std::cout<< "Not implemented for this detector" << std::endl;
setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE));
return -1;
}
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl;
#endif
if (connectData() == OK){
ret=thisReceiver->sendInt(fnum,retval,arg);
disconnectData();
}
if(ret==FAIL)
setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE));
else
thisDetector->receiver_deactivatedPaddingEnable = retval;
}
return thisDetector->receiver_deactivatedPaddingEnable;
}
int slsDetector::getFlippedData(dimension d) {
return thisDetector->flippedData[d];
}
@ -8662,7 +8747,7 @@ string slsDetector::checkReceiverOnline() {
dataSocket->SetTimeOut(5);
thisDetector->receiverOnlineFlag=OFFLINE_FLAG;
delete dataSocket;
dataSocket=NULL;
dataSocket=0;
#ifdef VERBOSE
std::cout<< "receiver offline!" << std::endl;
#endif
@ -8699,7 +8784,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
strcpy(thisDetector->receiver_hostname,thisName);
if (dataSocket){
delete dataSocket;
dataSocket=NULL;
dataSocket=0;
}
} else
strcpy(thisName,thisDetector->receiver_hostname);
@ -8713,28 +8798,30 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
thisDetector->receiverTCPPort=thisRP;
if (dataSocket){
delete dataSocket;
dataSocket=NULL;
dataSocket=0;
}
} else
thisRP=thisDetector->receiverTCPPort;
//create data socket
if (!dataSocket) {
dataSocket=new MySocketTCP(thisName, thisRP);
if (dataSocket->getErrorStatus()){
#ifdef VERBOSE
std::cout<< "Could not connect Data socket "<<thisName << " " <<
thisRP << std::endl;
#endif
delete dataSocket;
dataSocket=NULL;
retval=FAIL;
}
try {
dataSocket = new MySocketTCP(thisName, thisRP);
#ifdef VERYVERBOSE
else
std::cout<< "Data socket connected "<< thisName << " " << thisRP << std::endl;
std::cout<< "Data socket connected " <<
thisName << " " << thisRP << std::endl;
#endif
} catch(...) {
#ifdef VERBOSE
std::cout<< "Could not connect Data socket " <<
thisName << " " << thisRP << std::endl;
#endif
dataSocket = 0;
retval = FAIL;
}
}
//check if it connects
if (retval!=FAIL) {
checkReceiverOnline();
@ -8918,7 +9005,17 @@ int slsDetector::updateReceiverNoWait() {
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->receiver_upstream = ind;
// activate
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->activated = ind;
// deactivated padding enable
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->receiver_deactivatedPaddingEnable = ind;
// silent mode
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->receiver_silentMode = ind;
if (!n) printf("n: %d\n", n);
@ -9341,13 +9438,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;
}
@ -9359,11 +9449,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;
@ -9843,8 +9928,10 @@ int slsDetector::setReceiverSilentMode(int i) {
}
if(ret==FAIL)
setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET));
else
thisDetector->receiver_silentMode = retval;
}
return retval;
return thisDetector->receiver_silentMode;
}

View File

@ -375,6 +375,15 @@ private:
/** receiver partial frames padding enable */
bool receiver_framePadding;
/** activated receiver */
bool activated;
/** padding enable in deactivated receiver */
bool receiver_deactivatedPaddingEnable;
/** silent receiver */
bool receiver_silentMode;
} sharedSlsDetector;
@ -510,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
@ -573,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
@ -587,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)
@ -759,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
@ -769,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);
/**
@ -793,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();
@ -809,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
@ -824,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
@ -845,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
@ -860,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
@ -868,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,
@ -887,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
@ -956,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)
@ -969,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
@ -979,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
@ -988,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)
@ -997,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)
@ -1006,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)
@ -1069,6 +1078,12 @@ public:
*/
int stopAcquisition();
/**
* Give an internal software trigger to the detector (Eiger only)
* @return OK or FAIL
*/
int sendSoftwareTrigger();
/**
* Start readout (without exposure or interrupting exposure) (Mythen)
* @returns OK or FAIL
@ -1149,9 +1164,10 @@ public:
* Set/get timer value left in acquisition (not all implemented for all detectors)
* @param index timer index
* @param t time in ns or number of...(e.g. frames, gates, probes)
* @param imod module number
* @returns timer set value in ns or number of...(e.g. frames, gates, probes)
*/
int64_t getTimeLeft(timerIndex index);
int64_t getTimeLeft(timerIndex index, int imod = -1);
/**
* Set speed
@ -1259,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.
@ -1355,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
@ -1391,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
@ -1399,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)
@ -1439,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
@ -1455,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)
@ -1519,11 +1535,18 @@ public:
int writeAdcRegister(int addr, int val);
/**
* Activates the detector (Eiger only)
* Activates/Deactivates the detector (Eiger only)
* @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active)
* @returns 0 (inactive) or 1 (active)for activate mode
*/
int activate(int const enable=GET_ONLINE_FLAG);
int activate(int const enable=-1);
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
int setDeactivatedRxrPaddingMode(int padding=-1);
/**
* Returns the enable if data will be flipped across x or y axis (Eiger)
@ -1635,7 +1658,7 @@ public:
* @param fname file name
* @returns OK or FAIL
*/
int programFPGA(string fname);
int programFPGA(std::string fname);
/**
* Resets FPGA (Jungfrau)
@ -1822,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)
@ -1857,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)
@ -1882,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)
@ -1890,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)
@ -1898,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)
@ -1906,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)
@ -1942,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
@ -1951,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
@ -1964,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
@ -2005,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
@ -2213,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
@ -2371,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
@ -2406,7 +2429,7 @@ private:
* @param delay delay
* @returns transmission delay
*/
string setDetectorNetworkParameter(networkParameter index, int delay);
std::string setDetectorNetworkParameter(networkParameter index, int delay);
/**

View File

@ -373,7 +373,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual int64_t setTimer(timerIndex index, int64_t t=-1, int imod = -1)=0;
int64_t setExposureTime(int64_t t=-1, int imod = -1){return setTimer(ACQUISITION_TIME,t,imod);};
int64_t setSubFrameExposureTime(int64_t t=-1, int imod = -1){return setTimer(SUBFRAME_ACQUISITION_TIME,t,imod);};
int64_t setSubFramePeriod(int64_t t=-1, int imod = -1){return setTimer(SUBFRAME_PERIOD,t,imod);};
int64_t setSubFrameDeadTime(int64_t t=-1, int imod = -1){return setTimer(SUBFRAME_DEADTIME,t,imod);};
int64_t setExposurePeriod(int64_t t=-1, int imod = -1){return setTimer(FRAME_PERIOD,t,imod);};
int64_t setDelayAfterTrigger(int64_t t=-1, int imod = -1){return setTimer(DELAY_AFTER_TRIGGER,t,imod);};
int64_t setNumberOfGates(int64_t t=-1, int imod = -1){return setTimer(GATES_NUMBER,t,imod);};
@ -481,12 +481,19 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
*/
virtual int setOnline(int const online=-1)=0;
/** @short activates the detector (detector specific)
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state
\returns 0 (inactive) or 1 (active)
*/
virtual int activate(int const enable=GET_ONLINE_FLAG)=0;
/**
* Activates/Deactivates the detector (Eiger only)
* @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active)for activate mode
*/
virtual int activate(int const enable=-1)=0;
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
virtual int setDeactivatedRxrPaddingMode(int padding=-1)=0;
/**
@short set detector settings
@ -855,8 +862,8 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
}};
/** returns std::string from timer index
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER,PROBES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER, SUBFRAME_PERIOD
\returns std::string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number,probes_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number, subframe_period
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER,PROBES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER, SUBFRAME_DEADTIME
\returns std::string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number,probes_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number, SUBFRAME_DEADTIME
*/
static std::string getTimerType(timerIndex t){ \
switch (t) { \
@ -875,7 +882,7 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
case FRAMES_FROM_START_PG: return std::string("frames_from_start_pg"); \
case SAMPLES_JCTB: return std::string("samples_jctb"); \
case SUBFRAME_ACQUISITION_TIME: return std::string("subframe_acquisition_time"); \
case SUBFRAME_PERIOD: return std::string("subframe_period"); \
case SUBFRAME_DEADTIME: return std::string("subframe_deadtime"); \
case STORAGE_CELL_NUMBER: return std::string("storage_cell_number"); \
default: return std::string("unknown"); \
}};
@ -887,17 +894,17 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
\returns TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, TEMPERATURE_DCDC, TEMPERATURE_SODL,
TEMPERATURE_SODR, TEMPERATURE_FPGA2, TEMPERATURE_FPGA3, -1 when unknown mode
*/
static int getADCIndex(std::string s){
if (s=="temp_fpga") return TEMPERATURE_FPGA;
if (s=="temp_fpgaext") return TEMPERATURE_FPGAEXT;
if (s=="temp_10ge") return TEMPERATURE_10GE;
if (s=="temp_dcdc") return TEMPERATURE_DCDC;
if (s=="temp_sodl") return TEMPERATURE_SODL;
if (s=="temp_sodr") return TEMPERATURE_SODR;
if (s=="temp_fpgafl") return TEMPERATURE_FPGA2;
if (s=="temp_fpgafr") return TEMPERATURE_FPGA3;
return -1;
};
static int getADCIndex(std::string s){ \
if (s=="temp_fpga") return TEMPERATURE_FPGA; \
if (s=="temp_fpgaext") return TEMPERATURE_FPGAEXT; \
if (s=="temp_10ge") return TEMPERATURE_10GE; \
if (s=="temp_dcdc") return TEMPERATURE_DCDC; \
if (s=="temp_sodl") return TEMPERATURE_SODL; \
if (s=="temp_sodr") return TEMPERATURE_SODR; \
if (s=="temp_fpgafl") return TEMPERATURE_FPGA2; \
if (s=="temp_fpgafr") return TEMPERATURE_FPGA3; \
return -1; \
}; \
/**
@ -905,19 +912,43 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
\param s can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp
\returns E_Vcmp_ll, E_Vcmp_lr, E_Vcmp_rl, E_Vcmp_rr, THRESHOLD, E_Vrf, E_Vrs, E_Vtr, E_cal, E_Vcp , -1 when unknown mode
*/
static int getDACIndex(std::string s){
if (s=="vcmp_ll") return E_Vcmp_ll;
if (s=="vcmp_lr") return E_Vcmp_lr;
if (s=="vcmp_rl") return E_Vcmp_rl;
if (s=="vcmp_rr") return E_Vcmp_rr;
if (s=="vthreshold") return THRESHOLD;
if (s=="vrf") return E_Vrf;
if (s=="vrs") return E_Vrs;
if (s=="vtr") return E_Vtr;
if (s=="vcall") return E_cal;
if (s=="vcp") return E_Vcp;
return -1;
};
static int getDACIndex(std::string s){ \
if (s=="vcmp_ll") return E_Vcmp_ll; \
if (s=="vcmp_lr") return E_Vcmp_lr; \
if (s=="vcmp_rl") return E_Vcmp_rl; \
if (s=="vcmp_rr") return E_Vcmp_rr; \
if (s=="vthreshold") return THRESHOLD; \
if (s=="vrf") return E_Vrf; \
if (s=="vrs") return E_Vrs; \
if (s=="vtr") return E_Vtr; \
if (s=="vcall") return E_cal; \
if (s=="vcp") return E_Vcp; \
return -1; \
}; \
/**
@short returns receiver frame discard policy from std::string
\param s can be nodiscard, discardempty, discardpartial
\returns NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES, GET_FRAME_DISCARD_POLICY when unknown mode
*/
static frameDiscardPolicy getReceiverFrameDiscardPolicy(std::string s){ \
if (s=="nodiscard") return NO_DISCARD; \
if (s=="discardempty") return DISCARD_EMPTY_FRAMES; \
if (s=="discardpartial") return DISCARD_PARTIAL_FRAMES; \
return GET_FRAME_DISCARD_POLICY; \
}; \
/** returns std::string from frame discard policy
\param f can be NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES
\returns std::string nodiscard, discardempty, discardpartial, unknown
*/
static std::string getReceiverFrameDiscardPolicy(frameDiscardPolicy f){ \
switch (f) { \
case NO_DISCARD: return std::string("nodiscard"); \
case DISCARD_EMPTY_FRAMES: return std::string("discardempty"); \
case DISCARD_PARTIAL_FRAMES: return std::string("discardpartial"); \
default: return std::string("unknown"); \
}}; \
};

View File

@ -44,6 +44,12 @@ To address a specific controller i of detector j use:
<b>sls_detector_clnt j-i:cmd</b>
To use different shared memory segements for different detectors on the same
client pc, one can use environment variable <b>SLSDETNAME</b> set to any string to
different strings to make the shared memory segments unique. One can then use
the same multi detector id for both detectors as they have a different shared memory names.
For additional questions concerning the indexing of the detector, please refer to the SLS Detectors FAQ documentation.
The commands are sudivided into different pages depending on their functionalities:
@ -193,7 +199,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
/*! \page acquisition
- <b> status [s] </b> starts or stops acquisition in detector in non blocking mode. When using stop acquisition and if acquisition is done, it will restream the stop packet from receiver (if data streaming in receiver is on). \c s: [\c start, \c stop]. \c Returns the detector status: [\c running, \c error, \c transmitting, \c finished, \c waiting, \c idle]. \c Returns \c (string)
- <b> status [s] </b> starts or stops acquisition in detector in non blocking mode. When using stop acquisition and if acquisition is done, it will restream the stop packet from receiver (if data streaming in receiver is on). Eiger can also provide an internal software trigger. \c s: [\c start, \c stop, \c trigger(EIGER only)]. \c Returns the detector status: [\c running, \c error, \c transmitting, \c finished, \c waiting, \c idle]. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName="status"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdStatus;
@ -324,7 +330,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
++i;
/*! \page config
- <b>activate</b> Activates/Deactivates the detector. Deactivated detector does not send data. Used for EIGER only. \c Returns \c (int)
- <b>activate [b] [p]</b> Activates/Deactivates the detector. \c b is 1 for activate, 0 for deactivate. Deactivated detector does not send data. \c p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Used for EIGER only. \c Returns \c (int) (string)
*/
descrToFuncMap[i].m_pFuncName="activate"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
@ -501,7 +507,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
*/
/*! \page config
- <b>checkdetversion</b> Checks the version compatibility with detector software (if hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
- <b>checkdetversion</b> Checks the version compatibility with detector server (if hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName="checkdetversion"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN;
@ -509,7 +515,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
/*! \page config
- <b>checkrecversion</b> Checks the version compatibility with receiver software (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
- <b>checkrecversion</b> Checks the version compatibility with receiver server (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName="checkrecversion"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN;
@ -598,9 +604,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
/*! \page timing
- <b>subperiod [i]</b> sets/gets sub frame period in s. Used in EIGER only in 32 bit mode. \c Returns \c (double with 9 decimal digits)
- <b>subdeadtime [i]</b> sets/gets sub frame dead time in s. Subperiod is set in the detector = subexptime + subdeadtime. This value is normally a constant in the config file. Used in EIGER only in 32 bit mode. \c Returns \c (double with 9 decimal digits)
*/
descrToFuncMap[i].m_pFuncName="subperiod"; //
descrToFuncMap[i].m_pFuncName="subdeadtime"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++i;
@ -654,14 +660,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
/*! \page timing
- <b>storagecells [i]</b> sets/gets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells +1). \c Returns \c (long long int)
- <b>storagecells [i]</b> sets/gets number of additional storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells +1). \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName="storagecells"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>storagecell_start [i]</b> sets/gets the storage cell that stores the first acquisition of the series. Default is 0. For very advanced users only! For JUNGFRAU only. Range: 0-15. \c Returns \c (int)
- <b>storagecell_start [i]</b> sets/gets the storage cell that stores the first acquisition of the series. Default is 15(0xf).. For very advanced users only! For JUNGFRAU only. Range: 0-15. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="storagecell_start"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
@ -743,6 +749,20 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
++i;
/*! \page timing
- <b>measuredperiod</b> gets the measured frame period (time between last frame and the previous one) in s. For Eiger only. Makes sense only for acquisitions of more than 1 frame. \c Returns \c (double with 9 decimal digits)
*/
descrToFuncMap[i].m_pFuncName="measuredperiod"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
++i;
/*! \page timing
- <b>measuredsubperiod</b> gets the measured subframe period (time between last subframe and the previous one) in s. For Eiger only and in 32 bit mode. \c Returns \c (double with 9 decimal digits)
*/
descrToFuncMap[i].m_pFuncName="measuredsubperiod"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
++i;
/* speed */
/*! \page config
\section configspeed Speed
@ -2243,21 +2263,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
/*! \page receiver
- <b>r_framesperfile</b> sets/gets the frames per file in receiver. 0 means infinite or all frames in a single file. \c Returns \c (int)
- <b>r_framesperfile [i]</b> sets/gets the frames per file in receiver to i. 0 means infinite or all frames in a single file. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="r_framesperfile"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_framesperfile</b> sets/gets the frames per file in receiver. 0 means infinite or all frames in a single file. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="r_framesperfile"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_discardpolicy</b> sets/gets the frame discard policy in the receiver. 0 - no discard (default), 1 - discard only empty frames, 2 - discard any partial frame(fastest). \c Returns \c (int)
- <b>r_discardpolicy</b> sets/gets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="r_discardpolicy"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
@ -2652,9 +2665,12 @@ string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) {
if (string(args[1])=="start")
myDet->startAcquisition();
else if (string(args[1])=="stop") {
myDet->setReceiverOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);//restream stop
myDet->stopAcquisition();
}
else if (string(args[1])=="trigger") {
myDet->sendSoftwareTrigger();
}
else
return string("unknown action");
}
@ -2686,7 +2702,7 @@ string slsDetectorCommand::helpStatus(int narg, char *args[], int action) {
os << string("busy \t gets the status of acquire- can be: 0 or 1. 0 for idle, 1 for running\n");
}
if (action==PUT_ACTION || action==HELP_ACTION) {
os << string("status \t controls the detector acquisition - can be start or stop. When using stop acquisition and if acquisition is done, it will restream the stop packet from receiver (if data streaming in receiver is on). \n");
os << string("status \t controls the detector acquisition - can be start or stop or trigger(EIGER only). When using stop acquisition and if acquisition is done, it will restream the stop packet from receiver (if data streaming in receiver is on). Eiger can also provide an internal software trigger\n");
os << string("busy i\t sets the status of acquire- can be: 0(idle) or 1(running).Command Acquire sets it to 1 at beignning of acquire and back to 0 at the end. Clear Flag for unexpected acquire terminations. \n");
}
return os.str();
@ -4360,11 +4376,20 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&ival))
return string("Could not scan activate mode ")+string(args[1]);
/* if(dynamic_cast<slsDetector*>(myDet) != NULL)
return string("Can only set it from the multiDetector mode");*/
myDet->activate(ival);
bool padding = true;
if (narg > 2) {
if (string(args[2]) == "padding")
padding = true;
else if (string(args[2]) == "nopadding")
padding = false;
else
return string ("Could not scan activate mode's padding option " + string(args[2]));
myDet->setDeactivatedRxrPaddingMode(padding);
}
}
sprintf(ans,"%d",myDet->activate());
int ret = myDet->setDeactivatedRxrPaddingMode();
sprintf(ans,"%d %s", myDet->activate(), ret == 1 ? "padding" : (ret == 0 ? "nopadding" : "unknown"));
}
else if(cmd=="r_online"){
if (action==PUT_ACTION) {
@ -4395,14 +4420,14 @@ string slsDetectorCommand::helpOnline(int narg, char *args[], int action) {
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "online i \n sets the detector in online (1) or offline (0) mode"<< std::endl;
os << "r_online i \n sets the receiver in online (1) or offline (0) mode"<< std::endl;
os << "activate i \n sets the detector in activated (1) or deactivated (0) mode (does not send data). Only for Eiger."<< std::endl;
os << "activate i [p]\n sets the detector in activated (1) or deactivated (0) mode (does not send data). p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Only for Eiger."<< std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "online \n gets the detector online (1) or offline (0) mode"<< std::endl;
os << "checkonline \n returns the hostnames of all detectors in offline mode"<< std::endl;
os << "r_online \n gets the receiver online (1) or offline (0) mode"<< std::endl;
os << "r_checkonline \n returns the hostnames of all receiver in offline mode"<< std::endl;
os << "activate \n gets the detector activated (1) or deactivated (0) mode. Only for Eiger."<< std::endl;
os << "activate \n gets the detector activated (1) or deactivated (0) mode. And padding or nonpadding for the deactivated receiver. Only for Eiger."<< std::endl;
}
return os.str();
@ -4453,6 +4478,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!");
@ -4468,13 +4496,13 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
if ((val<0) || (narg!=((val*4)+2)) )
return helpDetectorSize(narg,args,action);
ROI allroi[val];
pos=1;
// std::cout << val << std::endl;
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)) )
// pos=1;
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)) )
return string("cannot parse arguments for roi");
}
myDet->setROI(val,allroi);
@ -4520,7 +4548,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
myDet->setReceiverOnline(ONLINE_FLAG);
ret=myDet->setDynamicRange(val);
} else if (cmd=="roi") {
myDet->getROI(ret);
ROI* r = myDet->getROI(ret);
if (myDet->isMultiSlsDetectorClass() && r != NULL)
delete [] r;
} else if (cmd=="detsizechan") {
sprintf(ans,"%d %d",myDet->getMaxNumberOfChannelsPerDetector(X),myDet->getMaxNumberOfChannelsPerDetector(Y));
return string(ans);
@ -4874,8 +4904,8 @@ string slsDetectorCommand::helpSN(int narg, char *args[], int action) {
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION) {
os << "checkdetversion \n gets the version compatibility with detector software (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl;
os << "checkrecversion \n gets the version compatibility with receiver software (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl;
os << "checkdetversion \n gets the version compatibility with detector server (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl;
os << "checkrecversion \n gets the version compatibility with receiver server (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl;
os << "moduleversion:i \n gets the firmwareversion of the module i"<< std::endl;
os << "modulenumber:i \n gets the serial number of the module i"<< std::endl;
os << "detectornumber \n gets the serial number of the detector (MAC)"<< std::endl;
@ -5649,8 +5679,8 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
index=SUBFRAME_ACQUISITION_TIME;
else if (cmd=="period")
index=FRAME_PERIOD;
else if (cmd=="subperiod")
index=SUBFRAME_PERIOD;
else if (cmd=="subdeadtime")
index=SUBFRAME_DEADTIME;
else if (cmd=="delay")
index=DELAY_AFTER_TRIGGER;
else if (cmd=="gates")
@ -5689,7 +5719,7 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
return string("cannot scan timer value ")+string(args[1]);
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME ||
index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER ||
index == SUBFRAME_PERIOD) {
index == SUBFRAME_DEADTIME) {
// +0.5 for precision of eg.0.0000325
t = ( val * 1E9 + 0.5);
}else t=(int64_t)val;
@ -5703,7 +5733,7 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
if ((ret!=-1) && (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME
|| index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER ||
index == SUBFRAME_PERIOD)) {
index == SUBFRAME_DEADTIME)) {
rval=(double)ret*1E-9;
sprintf(answer,"%0.9f",rval);
}
@ -5731,8 +5761,8 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "probes t \t sets the number of probes to accumulate (max 3! cycles should be set to 1, frames to the number of pump-probe events)" << std::endl;
os << "samples t \t sets the number of samples expected from the jctb" << std::endl;
os << "storagecells t \t sets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells+1)." << std::endl;
os << "storagecell_start t \t sets the storage cell that stores the first acquisition of the series. Default is 0. For very advanced users only! For JUNGFRAU only. Range: 0-15." << std::endl;
os << "subperiod t \t sets sub frame period in s. Used in EIGER only in 32 bit mode. " << std::endl;
os << "storagecell_start t \t sets the storage cell that stores the first acquisition of the series. Default is 15(0xf). For very advanced users only! For JUNGFRAU only. Range: 0-15." << std::endl;
os << "subdeadtime t \t sets sub frame dead time in s. Subperiod is set in the detector = subexptime + subdeadtime. This value is normally a constant in the config file. Used in EIGER only in 32 bit mode. " << std::endl;
os << std::endl;
@ -5749,7 +5779,7 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "samples \t gets the number of samples expected from the jctb" << std::endl;
os << "storagecells \t gets number of storage cells per acquisition.For JUNGFRAU only." << std::endl;
os << "storagecell_start \t gets the storage cell that stores the first acquisition of the series." << std::endl;
os << "subperiod \t gets sub frame period in s. Used in EIGER in 32 bit only." << std::endl;
os << "subperiod \t gets sub frame dead time in s. Used in EIGER in 32 bit only." << std::endl;
os << std::endl;
}
@ -5796,6 +5826,10 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) {
index=MEASUREMENT_TIME;
else if (cmd=="nframes")
index=FRAMES_FROM_START;
else if (cmd=="measuredperiod")
index=MEASURED_PERIOD;
else if (cmd=="measuredsubperiod")
index=MEASURED_SUBPERIOD;
else
return string("could not decode timer ")+cmd;
@ -5805,13 +5839,13 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) {
}
myDet->setOnline(ONLINE_FLAG);
ret=myDet->getTimeLeft(index);
if (index==ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER || index==ACTUAL_TIME || index==MEASUREMENT_TIME)
if ((ret!=-1) && (index==ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER
|| index==ACTUAL_TIME || index==MEASUREMENT_TIME ||
MEASURED_PERIOD || MEASURED_SUBPERIOD))
rval=(double)ret*1E-9;
else rval=ret;
@ -5839,6 +5873,8 @@ string slsDetectorCommand::helpTimeLeft(int narg, char *args[], int action) {
os << "framesl \t gets the number of frames left" << std::endl;
os << "cyclesl \t gets the number of cycles left" << std::endl;
os << "probesl \t gets the number of probes left" << std::endl;
os << "measuredperiod \t gets the measured frame period (time between last frame and the previous one) in s. For Eiger only. Makes sense only for acquisitions of more than 1 frame." << std::endl;
os << "measuredsubperiod \t gets the measured subframe period (time between last subframe and the previous one) in s. For Eiger only and in 32 bit mode." << std::endl;
os << std::endl;
}
@ -6409,14 +6445,12 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
else if(cmd=="r_discardpolicy") {
if (action==PUT_ACTION){
if (sscanf(args[1],"%d",&ival) && (ival >= 0) && (ival < NUM_DISCARD_POLICIES)) {
myDet->setReceiverFramesDiscardPolicy((frameDiscardPolicy)ival);
} else return string("could not scan frames discard policy\n");
frameDiscardPolicy f = myDet->getReceiverFrameDiscardPolicy(string(args[1]));
if (f == GET_FRAME_DISCARD_POLICY)
return string("could not scan frame discard policy. Options: nodiscard, discardempty, discardpartial\n");
myDet->setReceiverFramesDiscardPolicy(f);
}
char answer[100];
memset(answer, 0, 100);
sprintf(answer,"%d",myDet->setReceiverFramesDiscardPolicy());
return string(answer);
return myDet->getReceiverFrameDiscardPolicy(myDet->setReceiverFramesDiscardPolicy());
}
else if(cmd=="r_padding") {
@ -6450,7 +6484,7 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
os << "rx_fifodepth [val]\t sets receiver fifo depth to val" << std::endl;
os << "r_silent [i]\t sets receiver in silent mode, ie. it will not print anything during real time acquisition. 1 sets, 0 unsets." << std::endl;
os << "r_framesperfile s\t sets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
os << "r_discardpolicy s\t sets the frame discard policy in the receiver. 0 - no discard (default), 1 - discard only empty frames, 2 - discard any partial frame(fastest)." << std::endl;
os << "r_discardpolicy s\t sets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames." << std::endl;
os << "r_padding s\t enables/disables partial frames to be padded in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames." << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION){
@ -6462,7 +6496,7 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
os << "rx_fifodepth \t returns receiver fifo depth" << std::endl;
os << "r_silent \t returns receiver silent mode enable. 1 is silent, 0 not silent." << std::endl;
os << "r_framesperfile \t gets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
os << "r_discardpolicy \t gets the frame discard policy in the receiver. 0 - no discard (default), 1 - discard only empty frames, 2 - discard any partial frame(fastest)." << std::endl;
os << "r_discardpolicy \t gets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames." << std::endl;
os << "r_padding \t gets partial frames padding enable in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames." << std::endl;
}
return os.str();
@ -7014,7 +7048,8 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
}
}
os << hex << reg << dec;
if (myDet->isMultiSlsDetectorClass() && aa != NULL)
delete [] aa;
//os <<" "<< hex << myDet->readRegister(120) << dec;

View File

@ -6,26 +6,28 @@
using namespace std;
slsDetectorUsers::slsDetectorUsers(int id) : myDetector(NULL){
slsDetectorUsers::slsDetectorUsers(int& ret, int id) : myDetector(0), myCmd(0){
try {
myDetector=new multiSlsDetector(id);
} catch(...) {
ret = 1;
return;
}
myCmd=new multiSlsDetectorCommand(myDetector);
ret = 0;
myDetector=new multiSlsDetector(id);
myCmd=new multiSlsDetectorCommand(myDetector);
};
}
slsDetectorUsers::~slsDetectorUsers() {
if (myDetector)
delete myDetector;
};
}
string slsDetectorUsers::getDetectorDeveloper(){
return myDetector->getDetectorDeveloper();
}
int slsDetectorUsers::setOnline(int const online){
return myDetector->setOnline(online);
}
@ -42,7 +44,6 @@ int slsDetectorUsers::stopMeasurement(){
return myDetector->stopAcquisition();
}
int slsDetectorUsers::getDetectorStatus(){
return (int)myDetector->getRunStatus();
}
@ -51,12 +52,10 @@ string slsDetectorUsers::getFilePath(){
return myDetector->getFilePath();
}
string slsDetectorUsers::setFilePath(string s){
return myDetector->setFilePath(s);
}
string slsDetectorUsers::getFileName(){
return myDetector->getFileName();
}
@ -83,7 +82,7 @@ string slsDetectorUsers::setFlatFieldCorrectionDir(string dir){
string slsDetectorUsers::getFlatFieldCorrectionFile(){
return myDetector->getFlatFieldCorrectionFile();
};
}
int slsDetectorUsers::setFlatFieldCorrectionFile(string fname){
return myDetector->setFlatFieldCorrectionFile(fname);
@ -116,17 +115,37 @@ int slsDetectorUsers::getPositions(double *pos){
}
int slsDetectorUsers::setDetectorSize(int x0, int y0, int nx, int ny){
if(myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y)>1)
return 1;
int nmod=nx/(myDetector->getChansPerMod(0));
cout << myDetector->getChansPerMod(0) << " " << nx << " " << nmod << endl;
return myDetector->setNumberOfModules(nmod)*myDetector->getChansPerMod(0);}
// only one roi
slsDetectorDefs::ROI roi[1];
roi[0].xmin = x0;
roi[0].ymin = y0;
roi[0].xmax = x0 + nx;
roi[0].ymax = y0 + ny;
return myDetector->setROI(1, roi);
}
int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){
y0=0;
x0=0;
nx=myDetector->getTotalNumberOfChannels(slsDetectorDefs::X);
ny=myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y);
int n = 0;
slsDetectorDefs::ROI* roi = myDetector->getROI(n);
// roi
if (roi != NULL && n > 0) {
x0 = roi[0].xmin;
y0 = roi[0].ymin;
nx = roi[0].xmax - roi[0].xmin;
ny = roi[0].ymax - roi[0].ymin;
}
// no roi
else {
y0=0;
x0=0;
nx=myDetector->getTotalNumberOfChannels(slsDetectorDefs::X);
ny=myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y);
}
if (roi != NULL)
delete [] roi;
return nx*ny;
}
@ -140,7 +159,6 @@ int slsDetectorUsers::setBitDepth(int i){
return myDetector->setDynamicRange(i);
}
int slsDetectorUsers::setSettings(int isettings){
return myDetector->slsDetectorBase::setSettings(isettings);
}
@ -160,43 +178,40 @@ int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int id
double slsDetectorUsers::setExposureTime(double t, bool inseconds, int imod){
if(!inseconds)
return myDetector->setExposureTime((int64_t)t,imod);
else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setExposureTime(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setExposureTime(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int imod){
if(!inseconds)
return myDetector->setExposurePeriod((int64_t)t,imod);
else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setExposurePeriod(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setExposurePeriod(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int imod){
if(!inseconds)
return myDetector->setDelayAfterTrigger((int64_t)t,imod);
else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setDelayAfterTrigger(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setDelayAfterTrigger(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
int64_t slsDetectorUsers::setNumberOfGates(int64_t t, int imod){
@ -300,6 +315,44 @@ int slsDetectorUsers::enableGapPixels(int enable) {
return myDetector->enableGapPixels(enable);
}
std::string slsDetectorUsers::setReceiverFramesDiscardPolicy(std::string f) {
return myDetector->getReceiverFrameDiscardPolicy(
myDetector->setReceiverFramesDiscardPolicy(
myDetector->getReceiverFrameDiscardPolicy(f)));
}
int slsDetectorUsers::setReceiverPartialFramesPadding(int f) {
return myDetector->setReceiverPartialFramesPadding(f);
}
int slsDetectorUsers::setReceiverFramesPerFile(int f) {
return myDetector->setReceiverFramesPerFile(f);
}
int slsDetectorUsers::sendSoftwareTrigger() {
return myDetector->sendSoftwareTrigger();
}
double slsDetectorUsers::getMeasuredPeriod(bool inseconds, int imod) {
if(!inseconds)
return myDetector->getTimeLeft(slsReceiverDefs::MEASURED_PERIOD, imod);
int64_t tms = myDetector->getTimeLeft(slsReceiverDefs::MEASURED_PERIOD, imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int imod) {
if(!inseconds)
return myDetector->getTimeLeft(slsReceiverDefs::MEASURED_SUBPERIOD, imod);
int64_t tms = myDetector->getTimeLeft(slsReceiverDefs::MEASURED_SUBPERIOD, imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg){
myDetector->registerDataCallback(userCallback,pArg);
}
@ -337,8 +390,6 @@ void slsDetectorUsers::registerGetI0Callback( double (*func)(int,void*),void *ar
}
string slsDetectorUsers::putCommand(int narg, char *args[], int pos){
if(narg < 2)
return string("Error: Insufficient Parameters");
@ -352,8 +403,6 @@ string slsDetectorUsers::getCommand(int narg, char *args[], int pos){
}
int slsDetectorUsers::setClockDivider(int value) {
return myDetector->setClockDivider(value);
}
@ -402,7 +451,6 @@ int slsDetectorUsers::stopAcquisition() {
return myDetector->stopAcquisition();
}
int slsDetectorUsers::setReceiverSilentMode(int i) {
return myDetector->setReceiverSilentMode(i);
}
@ -431,21 +479,38 @@ int slsDetectorUsers::getNMods() {
return myDetector->getNMods();
}
double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds){
int64_t tms = (int64_t)(t * (1E+9));
if (t < 0) tms = -1;
if(!inseconds)
return myDetector->setSubFrameExposureTime((int64_t)t);
else
return ((1E-9) * (double)myDetector->setSubFrameExposureTime(tms));
double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds, int imod){
if(!inseconds)
return myDetector->setSubFrameExposureTime((int64_t)t,imod);
else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setSubFrameExposureTime(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
}
double slsDetectorUsers::setSubFrameExposurePeriod(double t, bool inseconds){
int64_t tms = (int64_t)(t * (1E+9));
if (t < 0) tms = -1;
if(!inseconds)
return myDetector->setSubFramePeriod((int64_t)t);
else
return ((1E-9) * (double)myDetector->setSubFramePeriod(tms));
double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool inseconds, int imod){
if(!inseconds)
return myDetector->setSubFrameDeadTime((int64_t)t,imod);
else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) tms = -1;
tms = myDetector->setSubFrameDeadTime(tms,imod);
if (tms < 0)
return -1;
return ((1E-9) * (double)tms);
}
}
int64_t slsDetectorUsers::setNumberOfStorageCells(int64_t t, int imod) {
return myDetector->setTimer(slsReceiverDefs::STORAGE_CELL_NUMBER, t, imod);
}
int slsDetectorUsers::setStoragecellStart(int pos) {
return myDetector->setStoragecellStart(pos);
}

View File

@ -25,7 +25,6 @@ class multiSlsDetectorCommand;
/*
\mainpage
<CENTER><H1>API for SLS detectors data acquisition</H1></CENTER>
@ -72,12 +71,11 @@ You can find examples of how this classes can be instatiated in mainClient.cpp
*/
/**
@libdoc The slsDetectorUsers class is a minimal interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration or parameters file that can be read/written.
*/
/**
@short Class for detector functionalities to embed the detector controls in the users custom interface e.g. EPICS, Lima etc.
@short The slsDetectorUsers class is a minimal interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration or parameters file that can be read/written.
Class for detector functionalities to embed the detector controls in the users custom interface e.g. EPICS, Lima etc.
*/
@ -87,23 +85,22 @@ class slsDetectorUsers
public:
/** @short default constructor */
slsDetectorUsers(int id=0);
/** @short default constructor
* @param ret address of return value. It will be set to 0 for success, else 1 for failure
* @param id multi detector id
* in creating multidetector object
*/
slsDetectorUsers(int& ret, int id=0);
/** @short virtual destructor */
virtual ~slsDetectorUsers();
/**
@short useful to define subset of working functions
\returns "PSI" or "Dectris"
*/
std::string getDetectorDeveloper();
/** @short sets the onlineFlag
\param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state
\returns 0 (offline) or 1 (online)
@ -250,7 +247,7 @@ class slsDetectorUsers
int getPositions(double *pos=NULL);
/**
@short sets the detector size
@short sets the detector size (only 1 ROI) (not Mythen supported anymore)
\param x0 horizontal position origin in channel number (-1 unchanged)
\param y0 vertical position origin in channel number (-1 unchanged)
\param nx number of channels in horiziontal (-1 unchanged)
@ -261,18 +258,16 @@ class slsDetectorUsers
/**
@short gets detector size
@short gets detector size (not Mythen supported anymore)
\param x0 horizontal position origin in channel number
\param y0 vertical position origin in channel number
\param nx number of channels in horiziontal
\param ny number of channels in vertical
\returns OK/FAIL
\returns total number of channels
*/
int getDetectorSize(int &x0, int &y0, int &nx, int &ny);
/**
@short gets the maximum detector size
\param x0 horizontal position origin in channel number
\param y0 vertical position origin in channel number
\param nx number of channels in horiziontal
\param ny number of channels in vertical
\returns OK/FAIL
@ -372,7 +367,6 @@ class slsDetectorUsers
\returns number of frames
*/
int64_t setNumberOfCycles(int64_t t=-1, int imod = -1);
/**
@short set/get the external communication mode
@ -420,6 +414,7 @@ class slsDetectorUsers
/**
@short register calbback for accessing detector final data, also enables data streaming in client and receiver (if receiver exists)
\param userCallback function for plotting/analyzing the data. Its arguments are the data structure d and the frame number f, s is for subframe number for eiger for 32 bit mode
\param pArg argument
*/
void registerDataCallback(int( *userCallback)(detectorData* d, int f, int s, void*), void *pArg);
@ -427,6 +422,7 @@ class slsDetectorUsers
/**
@short register callback for accessing raw data - if the rawDataCallback is registered, no filewriting/postprocessing will be carried on automatically by the software - the raw data are deleted by the software
\param userCallback function for postprocessing and saving the data - p is the pointer to the data, n is the number of channels
\param pArg argument
*/
void registerRawDataCallback(int( *userCallback)(double* p, int n, void*), void *pArg);
@ -463,7 +459,7 @@ class slsDetectorUsers
/** Enable or disable streaming data from receiver (creates transmitting sockets)
* @param enable 0 to disable 1 to enable -1 to only get the value
* @param i 0 to disable 1 to enable -1 to only get the value
* @returns data streaming from receiver enable
*/
int enableDataStreamingFromReceiver(int i=-1);
@ -502,7 +498,7 @@ class slsDetectorUsers
/** (for expert users)
* Set/Get client streaming in ZMQ IP
* By default, it is the IP of receiver hostname
* @param i sets, empty std::string gets
* @param ip sets, empty std::string gets
* @returns client streaming in ZMQ IP
*/
std::string setClientDataStreamingInIP(std::string ip="");
@ -552,42 +548,92 @@ class slsDetectorUsers
*/
int enableGapPixels(int enable=-1);
/**
* Sets the frames discard policy in receiver
* frame discard policy options:
* @param f nodiscard (default),discardempty, discardpartial (fastest), get to get the value
* @returns f nodiscard (default),discardempty, discardpartial (fastest)
*/
std::string setReceiverFramesDiscardPolicy(std::string f="get");
/**
* Sets the frame padding in receiver
* @param f 0 does not partial frames, 1 pads partial frames (-1 gets)
* @returns partial frames padding enable
*/
int setReceiverPartialFramesPadding(int f = -1);
/**
* Sets the frames per file in receiver
* @param f frames per file, 0 is infinite ie. every frame in same file (-1 gets)
* @returns frames per file
*/
int setReceiverFramesPerFile(int f = -1);
/**
* Sends a software internal trigger (EIGER only)
* @returns 0 for success, 1 for fail
*/
int sendSoftwareTrigger();
/**
* get measured period between previous two frames(EIGER only)
* @param inseconds true if the value is in s, else ns
* @param imod module number (-1 for all)
* @returns measured period
*/
double getMeasuredPeriod(bool inseconds=false, int imod = -1);
/**
* get measured sub period between previous two sub frames in 32 bit mode (EIGER only)
* @param inseconds true if the value is in s, else ns
* @param imod module number (-1 for all)
* @returns measured sub period
*/
double getMeasuredSubFramePeriod(bool inseconds=false, int imod = -1);
/**
@short register calbback for accessing detector final data
\param func function to be called at the end of the acquisition. gets detector status and progress index as arguments
\param pArg argument
*/
void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg);
/**
@short register calbback for reading detector position
\param func function for reading the detector position
\param arg argument
*/
void registerGetPositionCallback( double (*func)(void*),void *arg);
/**
@short register callback for connecting to the epics channels
\param func function for connecting to the epics channels
\param arg argument
*/
void registerConnectChannelsCallback( int (*func)(void*),void *arg);
/**
@short register callback to disconnect the epics channels
\param func function to disconnect the epics channels
\param arg argument
*/
void registerDisconnectChannelsCallback( int (*func)(void*),void *arg);
/**
@short register callback for moving the detector
\param func function for moving the detector
\param arg argument
*/
void registerGoToPositionCallback( int (*func)(double,void*),void *arg);
/**
@short register callback for moving the detector without waiting
\param func function for moving the detector
\param arg argument
*/
void registerGoToPositionNoWaitCallback( int (*func)(double,void*),void *arg);
/**
@short register calbback reading to I0
\param func function for reading the I0 (called with parameter 0 before the acquisition, 1 after and the return value used as I0)
\param arg argument
*/
void registerGetI0Callback( double (*func)(int,void*),void *arg);
@ -662,13 +708,13 @@ class slsDetectorUsers
/**
@short start receiver listening mode
\param returns OK or FAIL
\returns returns OK or FAIL
*/
int startReceiver();
/**
@short stop receiver listening mode
\param returns OK or FAIL
\returns returns OK or FAIL
*/
int stopReceiver();
@ -703,7 +749,7 @@ class slsDetectorUsers
/**
* reset frames caught in receiver
* should be called before startReceiver()
* @retuns OK or FAIL
* @returns OK or FAIL
*/
int resetFramesCaughtInReceiver();
@ -736,19 +782,37 @@ class slsDetectorUsers
/**
* Set sub frame exposure time (only for Eiger)
* @param i sub frame exposure time (-1 gets)
* @param t sub frame exposure time (-1 gets)
* @param inseconds true if the value is in s, else ns
* @param imod module number (-1 for all)
* @returns sub frame exposure time in ns, or s if specified
*/
double setSubFrameExposureTime(double t=-1, bool inseconds=false);
double setSubFrameExposureTime(double t=-1, bool inseconds=false, int imod = -1);
/**
* Set sub frame period (only for Eiger)
* @param i sub frame period (-1 gets)
* Set sub frame dead time (only for Eiger)
* Very advanced feature. Meant to be a constant in config file by an expert for each individual module
* @param t sub frame dead time (-1 gets)
* @param inseconds true if the value is in s, else ns
* @returns sub frame period in ns, or s if specified
* @param imod module number (-1 for all)
* @returns sub frame dead time in ns, or s if specified
*/
double setSubFrameExposurePeriod(double t=-1, bool inseconds=false);
double setSubFrameExposureDeadTime(double t=-1, bool inseconds=false, int imod = -1);
/**
* set/get number of additional storage cells (Jungfrau)
* @param t number of additional storage cells. Default is 0. (-1 gets)
* @param imod module number (-1 for all)
* @returns number of additional storage cells
*/
int64_t setNumberOfStorageCells(int64_t t=-1, int imod = -1);
/**
* Set storage cell that stores first acquisition of the series (Jungfrau)
* @param pos storage cell index. Value can be 0 to 15. Default is 15. (-1 gets)
* @returns the storage cell that stores the first acquisition of the series
*/
int setStoragecellStart(int pos=-1);
/************************************************************************
@ -829,12 +893,12 @@ class slsDetectorUsers
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode
*/
static int getTimingMode(std::string s){ \
static int getTimingMode(std::string s){ \
if (s== "auto") return 0; \
if (s== "trigger") return 1; \
if (s== "ro_trigger") return 2; \
if (s== "gating") return 3; \
if (s== "triggered_gating") return 4; \
if (s== "triggered_gating") return 4; \
return -1; };

View File

@ -291,9 +291,10 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
get current timer value
\param index timer index
\param imod module number
\returns elapsed time value in ns or number of...(e.g. frames, gates, probes)
*/
virtual int64_t getTimeLeft(timerIndex index)=0;
virtual int64_t getTimeLeft(timerIndex index, int imod = -1)=0;
/**
* set storage cell that stores first acquisition of the series (Jungfrau only)
@ -475,6 +476,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
int acquire(int delflag=1);
/**
* Give an internal software trigger to the detector (Eiger only)
* @return OK or FAIL
*/
virtual int sendSoftwareTrigger()=0;
// double* convertAngles(){return convertAngles(currentPosition);};
// virtual double* convertAngles(double pos)=0;

View File

@ -21,7 +21,12 @@ class detectorData {
\param dr dynamic range or bits per pixel (valid only for non MYTHEN detectors)
\param file_ind file index
*/
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double f_ind=-1, const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0, int dr=0, long long int file_ind=-1) : values(val), errors(err), angles(ang), progressIndex(f_ind), npoints(np), npy(ny), cvalues(cval), databytes(dbytes), dynamicRange(dr), dgainvalues(NULL), fileIndex(file_ind) {
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double f_ind=-1,
const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0, int dr=0,
long long int file_ind=-1) :
values(val), errors(err), angles(ang), progressIndex(f_ind),
npoints(np), npy(ny), cvalues(cval), databytes(dbytes),
dynamicRange(dr), dgainvalues(NULL), fileIndex(file_ind) {
strcpy(fileName,fname);
};
@ -30,7 +35,8 @@ class detectorData {
deletes also the arrays pointing to data/errors/angles if not NULL
cvalues are deleted by caller
*/
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if(dgainvalues) delete [] dgainvalues;};
~detectorData() {if (values) delete [] values; if (errors) delete [] errors;
if (angles) delete [] angles; if(dgainvalues) delete [] dgainvalues;};
//private:
double *values; /**< @short pointer to the data as double array (MYTHEN only) */
double *errors; /**< @short pointer to the errors */

View File

@ -118,9 +118,7 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
int selectStoragecellStart(int pos);
#endif
int64_t setTimer(enum timerIndex ind, int64_t val);
#ifndef EIGERD
int64_t getTimeLeft(enum timerIndex ind);
#endif
// parameters - channel, chip, module, settings
@ -255,6 +253,9 @@ int startStateMachine();
void* start_timer(void* arg);
#endif
int stopStateMachine();
#ifdef EIGERD
int softwareTrigger();
#endif
#ifndef JUNGFRAUD
int startReadOut();
#endif

View File

@ -113,7 +113,7 @@ int decode_function(int file_des) {
#ifdef JUNGFRAUD
if ((debugflag == PROGRAMMING_MODE) &&
((fnum != F_PROGRAM_FPGA) && (fnum != F_GET_DETECTOR_TYPE) &&
(fnum != F_RESET_FPGA) && (fnum != F_UPDATE_CLIENT))) {
(fnum != F_RESET_FPGA) && (fnum != F_UPDATE_CLIENT) && (fnum != F_CHECK_VERSION))) {
sprintf(mess,"This Function %s cannot be executed. ", getFunctionName((enum detFuncs)fnum));
ret=(M_nofuncMode)(file_des);
} else
@ -210,6 +210,7 @@ const char* getFunctionName(enum detFuncs func) {
case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START";
case F_CHECK_VERSION: return "F_CHECK_VERSION";
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
default: return "Unknown Function";
}
@ -295,6 +296,7 @@ void function_table() {
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
flist[F_STORAGE_CELL_START] = &storage_cell_start;
flist[F_CHECK_VERSION] = &check_version;
flist[F_SOFTWARE_TRIGGER] = &software_trigger;
// check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@ -2787,6 +2789,9 @@ int set_timer(int file_des) {
else {
#ifdef VERBOSE
printf("setting timer %d to %lld ns\n",ind,tns);
#endif
#ifdef EIGERD
int64_t subexptime = 0;
#endif
switch(ind) {
#ifdef JUNGFRAUD
@ -2794,6 +2799,7 @@ int set_timer(int file_des) {
if (tns > MAX_STORAGE_CELL_VAL) {
ret=FAIL;
strcpy(mess,"Max Storage cell number should not exceed 15\n");
cprintf(RED, "Warning: %s", mess);
break;
}
#endif
@ -2802,14 +2808,19 @@ int set_timer(int file_des) {
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
ret=FAIL;
strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n");
cprintf(RED, "Warning: %s", mess);
break;
}
retval = setTimer(ind,tns);
break;
case SUBFRAME_PERIOD:
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
case SUBFRAME_DEADTIME:
subexptime = setTimer(SUBFRAME_ACQUISITION_TIME, -1);
if ((tns + subexptime) > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
ret=FAIL;
strcpy(mess,"Sub Frame Period should not exceed 5.368 seconds\n");
sprintf(mess,"Sub Frame Period should not exceed 5.368 seconds. "
"So sub frame dead time should not exceed %lfu seconds (subexptime = %lf seconds)\n",
((((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) - subexptime)/1E9), (subexptime/1E9));
cprintf(RED, "Warning: %s", mess);
break;
}
retval = setTimer(ind,tns);
@ -2885,16 +2896,6 @@ int get_time_left(int file_des) {
sprintf(mess,"get timer left failed\n");
#ifdef EIGERD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Get Timer Left) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
// receive arguments
enum timerIndex ind=0;
n = receiveData(file_des,&ind,sizeof(ind),INT32);
@ -2914,7 +2915,10 @@ int get_time_left(int file_des) {
#endif
switch(ind) {
#ifdef MYTHEND
#ifdef EIGERD
case MEASURED_PERIOD:
case MEASURED_SUBPERIOD:
#elif MYTHEND
case PROBES_NUMBER:
#elif JUNGFRAUD
case FRAMES_FROM_START:
@ -2924,6 +2928,7 @@ int get_time_left(int file_des) {
case PROBES_NUMBER:
case SAMPLES_JCTB:
#endif
#ifndef EIGERD
#ifndef JUNGFRAUD
case GATES_NUMBER:
#endif
@ -2935,6 +2940,7 @@ int get_time_left(int file_des) {
case PROGRESS:
case ACTUAL_TIME:
case MEASUREMENT_TIME:
#endif
retval=getTimeLeft(ind);
break;
default:
@ -2954,7 +2960,7 @@ int get_time_left(int file_des) {
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
@ -3654,7 +3660,7 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
#ifdef SLS_DETECTOR_FUNCTION_LIST
retval=setTimer(SUBFRAME_PERIOD,GET_FLAG);
retval=setTimer(SUBFRAME_DEADTIME,GET_FLAG);
#endif
n = sendData(file_des,&retval,sizeof(int64_t),INT64);
if (n < 0) return printSocketReadError();
@ -5842,7 +5848,7 @@ int check_version(int file_des) {
sprintf(mess,"Client's detector SW API version: (0x%llx). "
"Detector's SW API Version: (0x%llx). "
"Incompatible, update client!\n",
client_requiredVersion, det_apiVersion);
(long long int)client_requiredVersion, (long long int)det_apiVersion);
cprintf(RED, "Warning: %s", mess);
}
@ -5852,7 +5858,7 @@ int check_version(int file_des) {
sprintf(mess,"Detector SW Version: (0x%llx). "
"Client's detector SW API Version: (0x%llx). "
"Incompatible, update detector software!\n",
det_version, client_requiredVersion);
(long long int)det_version, (long long int)client_requiredVersion);
cprintf(RED, "Warning: %s", mess);
}
}
@ -5871,3 +5877,52 @@ int check_version(int file_des) {
// return ok / fail
return ret;
}
int software_trigger(int file_des) {
int ret=OK,ret1=OK;
int n=0;
sprintf(mess,"software trigger failed\n");
#ifndef EIGERD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Software Trigger) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
// execute action
if (differentClients && lockStatus) {
ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else {
printf("Software Trigger\n");
ret=softwareTrigger();
if (ret==FAIL)
cprintf(RED, "Warning: %s", mess);
}
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}

View File

@ -96,5 +96,6 @@ int temp_event(int);
int auto_comp_disable(int);
int storage_cell_start(int);
int check_version(int);
int software_trigger(int);
#endif

View File

@ -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;
}

View File

@ -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: