This commit is contained in:
2018-08-08 12:06:14 +02:00
216 changed files with 23718 additions and 22233 deletions

View File

@ -1,5 +1,6 @@
set(SOURCES
multiSlsDetector/multiSlsDetector.cpp
sharedMemory/SharedMemory.cpp
slsDetector/slsDetectorUsers.cpp
slsDetector/slsDetectorUtils.cpp
slsDetector/slsDetectorCommand.cpp
@ -24,6 +25,7 @@ set(HEADERS
include_directories(
commonFiles
multiSlsDetector
sharedMemory
slsDetector
slsDetectorUtils
slsDetectorCommand
@ -39,12 +41,6 @@ add_definitions(
-DDACS_INT
)
add_library(zmq STATIC IMPORTED )
set_target_properties(zmq PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../slsReceiverSoftware/include/libzmq.a
)
add_library(slsDetectorStatic STATIC
${SOURCES}
${HEADERS}
@ -63,6 +59,9 @@ 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
slsDetector/slsDetector.h
slsDetector/slsDetectorActions.h

View File

@ -9,15 +9,15 @@ CFLAGS= -g -DC_ONLY -fPIC
DFLAGS= -g -DDACS_INT
INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -I$(ASM)
INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM)
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom
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 #../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
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
@ -43,7 +43,7 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC)
cd gotthardDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR)
%.o : %.cpp %.h $(DEPSINCLUDES) Makefile
%.o : %.cpp %.h $(DEPSINCLUDES) Makefile
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) $(FLAGS)

View File

@ -15,7 +15,7 @@
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
//
/** Error flags */
/*Assumption: Only upto 63 detectors */
@ -51,6 +51,7 @@ using namespace std;
#define PREPARE_ACQUISITION 0x0000100000000000ULL
#define CLEANUP_ACQUISITION 0x0000080000000000ULL
#define REGISER_WRITE_READ 0x0000040000000000ULL
#define VERSION_COMPATIBILITY 0x0000020000000000ULL
// 0xFFFFFF0000000000ULL
// 0x000000FFFFFFFFFFULL
@ -86,13 +87,14 @@ using namespace std;
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL
#define THRESHOLD_NOT_SET 0x0000000040000000ULL
#define RECEIVER_FILE_FORMAT 0x0000000080000000ULL
#define RECEIVER_SILENT_MODE_NOT_SET 0x0000000100000000ULL
#define RECEIVER_PARAMETER_NOT_SET 0x0000000100000000ULL
#define RECEIVER_TIMER_NOT_SET 0x0000000200000000ULL
#define RECEIVER_ENABLE_GAPPIXELS_NOT_SET 0x0000000400000000ULL
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000800000000ULL
#define TEMPERATURE_CONTROL 0x0000001000000000ULL
#define AUTO_COMP_DISABLE 0x0000002000000000ULL
#define CONFIG_FILE 0x0000004000000000ULL
#define STORAGE_CELL_START 0x0000008000000000ULL
// 0x000000FFFFFFFFFFULL
@ -111,9 +113,9 @@ public:
* param errorMask error mask
/returns error message from error mask
*/
static string getErrorMessage(int64_t slsErrorMask){
static std::string getErrorMessage(int64_t slsErrorMask){
string retval = "";
std::string retval = "";
if(slsErrorMask&CANNOT_CONNECT_TO_DETECTOR)
retval.append("Cannot connect to Detector\n");
@ -169,13 +171,16 @@ public:
if(slsErrorMask&REGISER_WRITE_READ)
retval.append("Could not read/write register in detector\n");
if(slsErrorMask&VERSION_COMPATIBILITY)
retval.append("Incompatible versions with detector or receiver. Please check log for more details.\n");
if(slsErrorMask&COULD_NOT_CONFIGURE_MAC)
retval.append("Could not configure mac\n");
if(slsErrorMask&COULDNOT_SET_NETWORK_PARAMETER)
retval.append("Could not set network parameter. Should be valid and in proper format\n");
retval.append("Could not set network parameter.\n");
if(slsErrorMask&COULDNOT_SET_ROI)
retval.append("Could not set the exact region of interest. Verify ROI set by detector.\n");
@ -276,8 +281,8 @@ public:
if(slsErrorMask&RECEIVER_TIMER_NOT_SET)
retval.append("Could not set timer in receiver.\n");
if(slsErrorMask&RECEIVER_SILENT_MODE_NOT_SET)
retval.append("Could not set silent mode in receiver.\n");
if(slsErrorMask&RECEIVER_PARAMETER_NOT_SET)
retval.append("Could not set a paramater in receiver.\n");
if(slsErrorMask&RECEIVER_ENABLE_GAPPIXELS_NOT_SET)
retval.append("Could not enable/disable gap pixels in receiver.\n");

View File

@ -22,6 +22,9 @@
/** maximum rois */
#define MAX_ROIS 100
/** maximum trim en */
#define MAX_TRIMEN 100
/** maximum unit size of program sent to detector */
#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024)
@ -196,7 +199,10 @@ enum networkParameter {
RECEIVER_STREAMING_PORT, /**< receiever streaming TCP(ZMQ) port */
CLIENT_STREAMING_PORT, /**< client streaming TCP(ZMQ) port */
RECEIVER_STREAMING_SRC_IP,/**< receiever streaming TCP(ZMQ) ip */
CLIENT_STREAMING_SRC_IP /**< client streaming TCP(ZMQ) ip */
CLIENT_STREAMING_SRC_IP, /**< client streaming TCP(ZMQ) ip */
ADDITIONAL_JSON_HEADER, /**< additional json header (ZMQ) */
RECEIVER_UDP_SCKT_BUF_SIZE, /**< UDP socket buffer size */
RECEIVER_REAL_UDP_SCKT_BUF_SIZE /**< real UDP socket buffer size */
};
/**
@ -288,7 +294,9 @@ enum idMode{
DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */
THIS_SOFTWARE_VERSION, /**<return this software version */
RECEIVER_VERSION, /**<return receiver software version */
SOFTWARE_FIRMWARE_API_VERSION /** return software firmware API version **/
SOFTWARE_FIRMWARE_API_VERSION, /** return software firmware API version **/
CLIENT_SOFTWARE_API_VERSION, /** return detector software and client api version */
CLIENT_RECEIVER_API_VERSION /** return client and receiver api version */
};
/**
detector digital test modes
@ -487,6 +495,8 @@ enum readOutFlags {
DIGITAL_ONLY=0x80000, /** chiptest board read only digital bits (not adc values)*/
ANALOG_AND_DIGITAL=0x100000, /** chiptest board read adc values and digital bits digital bits */
DUT_CLK=0x200000, /** chiptest board fifo clock comes from device under test */
SHOW_OVERFLOW=0x400000, /** eiger 32 bit mode, show saturated for overflow of single subframes */
NOOVERFLOW=0x800000 /** eiger 32 bit mode, do not show saturated for overflow of single subframes */
};
/**
trimming modes

View File

@ -0,0 +1,25 @@
#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

@ -118,6 +118,9 @@ enum detFuncs{
F_TEMP_EVENT, /** < set temperature event */
F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
F_STORAGE_CELL_START, /** < storage cell start */
F_CHECK_VERSION, /** < check version compatibility */
/* Always append functions hereafter!!! */
/* Always append functions before!!! */

View File

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

View File

@ -49,6 +49,7 @@
int Beb_activated = 1;
uint32_t Beb_detid = 0;
int Beb_top =0;
@ -164,8 +165,10 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal){
ret = Beb_Read32(csp0base, MODULE_CONFIGURATION_MASK);
printf("Module Configuration OK\n");
printf("Beb: value =0x%x\n",ret);
if(ret&TOP_BIT_MASK)
if(ret&TOP_BIT_MASK) {
*top = 1;
Beb_top = 1;
}
if(ret&MASTER_BIT_MASK)
*master = 1;
if(ret&NORMAL_MODULE_BIT_MASK)
@ -412,6 +415,43 @@ int Beb_Activate(int enable){
}
int Beb_Set32bitOverflow(int val) {
if(!Beb_activated)
return val;
//mapping new memory
u_int32_t* csp0base=0;
u_int32_t valueread = 0;
u_int32_t offset = FLOW_REG_OFFSET;
if(val>0) val = 1;
//open file pointer
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
if(fd < 0){
cprintf(BG_RED,"Could not read register to set overflow flag in 32 bit mode. FAIL\n");
return -1;
}
else{
if(val > -1){
// reset bit
valueread = Beb_Read32(csp0base, offset);
Beb_Write32(csp0base, offset,valueread & ~FLOW_REG_OVERFLOW_32_BIT_MSK);
// set bit
valueread = Beb_Read32(csp0base, offset);
Beb_Write32(csp0base, offset,valueread |
((val << FLOW_REG_OVERFLOW_32_BIT_OFST) & FLOW_REG_OVERFLOW_32_BIT_MSK));
}
valueread = (Beb_Read32(csp0base, offset) & FLOW_REG_OVERFLOW_32_BIT_MSK) >> FLOW_REG_OVERFLOW_32_BIT_OFST;
}
//close file pointer
if(fd > 0)
Beb_close(fd,csp0base);
return valueread;
}
int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){
if(!Beb_activated)
@ -438,7 +478,7 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){
strcpy(modename,"Transmission Delay Frame");
break;
case FLOWCTRL_10G:
offset = TXM_FLOW_CONTROL_10G;
offset = FLOW_REG_OFFSET;
strcpy(modename,"Flow Control for 10G");
if(val>0) val = 1;
break;
@ -452,14 +492,29 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){
}
else{
if(val > -1){
valueread = Beb_Read32(csp0base, offset);
//cprintf(BLUE, "%s value before:%d\n",modename,valueread);
Beb_Write32(csp0base, offset,val);
cprintf(BLUE,"%s value:%d\n", modename,valueread);
if (mode != FLOWCTRL_10G) {
valueread = Beb_Read32(csp0base, offset);
Beb_Write32(csp0base, offset,val);
}
// flow control reg has other bits for other control
else {
// reset bit
valueread = Beb_Read32(csp0base, offset);
Beb_Write32(csp0base, offset,valueread & ~FLOW_REG_TXM_FLOW_CNTRL_10G_MSK);
// set bit
valueread = Beb_Read32(csp0base, offset);
Beb_Write32(csp0base, offset,valueread |
((val << FLOW_REG_TXM_FLOW_CNTRL_10G_OFST) & FLOW_REG_TXM_FLOW_CNTRL_10G_MSK));
}
}
valueread = Beb_Read32(csp0base, offset);
//cprintf(BLUE,"%s value:%d\n", modename,valueread);
if (mode == FLOWCTRL_10G)
valueread = (valueread & FLOW_REG_TXM_FLOW_CNTRL_10G_MSK) >> FLOW_REG_TXM_FLOW_CNTRL_10G_OFST;
}
//close file pointer
if(fd > 0)
@ -1161,7 +1216,7 @@ int Beb_SetDetectorPosition(int pos[]) {
if(!Beb_activated)
return OK;
pos[0] = Beb_swap_uint16(pos[0]);
pos[1] = Beb_swap_uint16(pos[1]);
pos[2] = Beb_swap_uint16(pos[2]);
int ret = FAIL;
@ -1176,37 +1231,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 | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
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) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
if((value & UDP_HEADER_X_MSK) != ((posval << 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 | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
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) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
ret = FAIL;
// y left
int posval = Beb_swap_uint16(pos[1]);
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
// y right
posval = Beb_swap_uint16(pos[1]+1);
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
@ -1235,8 +1290,8 @@ int Beb_SetDetectorPosition(int pos[]) {
cprintf(BLUE, "Position set to...\n"
"Left: [%d, %d, %d]\n"
"Right:[%d, %d, %d]\n",
Beb_swap_uint16(pos[0]), pos[1], Beb_swap_uint16(pos[2]),
Beb_swap_uint16(pos[0]), pos[1]+1, Beb_swap_uint16(pos[2]));
(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]));
}
return ret;

View File

@ -51,6 +51,7 @@ struct BebInfo{
int Beb_SetMasterViaSoftware();
int Beb_SetSlaveViaSoftware();
int Beb_Activate(int enable);
int Beb_Set32bitOverflow(int val);
int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val);
int Beb_ResetToHardwareSettings();
u_int32_t Beb_GetFirmwareRevision();

View File

@ -42,6 +42,7 @@ unsigned int Feb_Control_subFrameMode;
unsigned int Feb_Control_nimages;
double Feb_Control_exposure_time_in_sec;
int64_t Feb_Control_subframe_exposure_time_in_10nsec;
int64_t Feb_Control_subframe_period_in_10nsec;
double Feb_Control_exposure_period_in_sec;
int64_t Feb_Control_RateTable_Tau_in_nsec = -1;
@ -1380,6 +1381,14 @@ int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10
}
int64_t Feb_Control_GetSubFrameExposureTime(){return Feb_Control_subframe_exposure_time_in_10nsec*10;}
int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec){
Feb_Control_subframe_period_in_10nsec = the_subframe_period_in_10nsec;
printf("Sub Frame Period set to: %lld\n",(long long int)Feb_Control_subframe_period_in_10nsec);
return 1;
}
int64_t Feb_Control_GetSubFramePeriod(){return Feb_Control_subframe_period_in_10nsec*10;}
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec){
Feb_Control_exposure_period_in_sec = the_exposure_period_in_sec;
printf("Exposure period set to: %f\n",Feb_Control_exposure_period_in_sec);
@ -1510,9 +1519,11 @@ int Feb_Control_PrepareForAcquisition(){//return 1;
reg_vals[4]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
reg_nums[5]=DAQ_REG_SUBFRAME_EXPOSURES;
reg_vals[5]= Feb_Control_subframe_exposure_time_in_10nsec; //(1 means 10ns, 100 means 1000ns)
reg_nums[6]=DAQ_REG_SUBFRAME_PERIOD;
reg_vals[6]= Feb_Control_subframe_period_in_10nsec; //(1 means 10ns, 100 means 1000ns)
// if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0)){
if(Feb_Control_activated){
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),6,reg_nums,reg_vals,0,0)){
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),7,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}

View File

@ -164,6 +164,8 @@ int Feb_Control_GetModuleNumber();
int64_t Feb_Control_GetExposureTime_in_nsec();
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec);
int64_t Feb_Control_GetSubFrameExposureTime();
int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec);
int64_t Feb_Control_GetSubFramePeriod();
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
double Feb_Control_GetExposurePeriod();
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);

View File

@ -6,19 +6,28 @@
//daq register definitions
#define DAQ_REG_CTRL 1
#define DAQ_REG_CHIP_CMDS 2
#define DAQ_REG_STATIC_BITS 3
#define DAQ_REG_CLK_ROW_CLK_NTIMES 3
#define DAQ_REG_SHIFT_IN_32 3
#define DAQ_REG_READOUT_NROWS 3
#define DAQ_REG_SEND_N_TESTPULSES 3
#define DAQ_REG_CTRL 1
#define DAQ_REG_CHIP_CMDS 2
#define DAQ_REG_STATIC_BITS 3
#define DAQ_REG_CLK_ROW_CLK_NTIMES 3
#define DAQ_REG_SHIFT_IN_32 3
#define DAQ_REG_READOUT_NROWS 3
#define DAQ_REG_SEND_N_TESTPULSES 3
#define DAQ_REG_NEXPOSURES 3
#define DAQ_REG_EXPOSURE_TIMER 4 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_SUBFRAME_EXPOSURES 6
#define DAQ_REG_SUBFRAME_PERIOD 7 //also pg and fifo status register
#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_NEXPOSURES 3
#define DAQ_REG_EXPOSURE_TIMER 4 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_SUBFRAME_EXPOSURES 6
#define DAQ_REG_STATUS 7 //also pg and fifo status register
#define DAQ_CTRL_RESET 0x80000000
#define DAQ_CTRL_START 0x40000000
@ -130,7 +139,12 @@
#define TXM_DELAY_LEFT_OFFSET 0x180
#define TXM_DELAY_RIGHT_OFFSET 0x1A0
#define TXM_DELAY_FRAME_OFFSET 0x1C0
#define TXM_FLOW_CONTROL_10G 0x140
#define FLOW_REG_OFFSET 0x140
#define FLOW_REG_TXM_FLOW_CNTRL_10G_OFST (0)
#define FLOW_REG_TXM_FLOW_CNTRL_10G_MSK (0x1 << FLOW_REG_TXM_FLOW_CNTRL_10G_OFST)
#define FLOW_REG_OVERFLOW_32_BIT_OFST (2)
#define FLOW_REG_OVERFLOW_32_BIT_MSK (0x1 << FLOW_REG_OVERFLOW_32_BIT_OFST)
//command memory
#define LEFT_OFFSET 0x0
@ -152,9 +166,6 @@
#define FRAME_NUM_RESET_OFFSET 0xA0
//temp so far
#define FEB_REG_STATUS 0xa
//1g counters
#define ONE_GIGA_LEFT_INDEX_LSB_COUNTER 0x04
#define ONE_GIGA_LEFT_INDEX_MSB_COUNTER 0x24

View File

@ -6,7 +6,7 @@ LDLIBS += -lm -lstdc++ -pthread
DESTDIR ?= bin
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList_virtual.c
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c

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: da010a03d725b6f18020d2142d58771534414274
Revision: 328
Repsitory UUID: 3b6ead77836f2b6d2a795a9a994259d1dc8c131d
Revision: 343
Branch: developer
Last Changed Author: Erik_Frojdh
Last Changed Rev: 3751
Last Changed Date: 2018-04-03 16:29:39.000000002 +0200 ./xparameters.h
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3943
Last Changed Date: 2018-07-17 16:15:43.000000002 +0200 ./Makefile.virtual

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "da010a03d725b6f18020d2142d58771534414274"
#define GITAUTH "Erik_Frojdh"
#define GITREV 0x3751
#define GITDATE 0x20180403
#define GITREPUUID "3b6ead77836f2b6d2a795a9a994259d1dc8c131d"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3943
#define GITDATE 0x20180717
#define GITBRANCH "developer"

View File

@ -73,9 +73,13 @@ enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_SUBFRAME_EXPOSURE_VAL (2621440) // 2.6ms
#define DEFAULT_SUBFRAME_EXPOSURE (2621440) // 2.6ms
#define DEFAULT_SUBFRAME_PERIOD (0)
#define DEFAULT_DYNAMIC_RANGE (16)
#define DEFAULT_READOUT_FLAG (NONPARALLEL)
#define DEFAULT_READOUT_MODE (NONPARALLEL)
#define DEFAULT_READOUT_STOREINRAM_MODE (CONTINOUS_RO)
#define DEFAULT_READOUT_OVERFLOW32_MODE (NOOVERFLOW)
#define DEFAULT_CLK_SPEED (HALF_SPEED)
#define DEFAULT_IO_DELAY (650)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)

View File

@ -0,0 +1,7 @@
SRCFILE=gitInfoEiger.h
DSTFILE=versionAPI.h
SRCPATTERN=GITDATE
DSTPATTERN=APIEIGER
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE

View File

@ -0,0 +1 @@
../commonFiles/versionAPI.h

View File

@ -16,7 +16,7 @@
#include <math.h>
using namespace std;

View File

@ -1,18 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
<<<<<<< HEAD
Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b
Revision: 1846
Branch: developer
Last Changed Author: Anna_Bergamaschi
Last Changed Rev: 3731
Last Changed Date: 2018-03-15 12:30:34.000000002 +0100 ./threadFiles/ThreadPool.o
=======
Repsitory UUID: b8bdbf4da61f95b88893b02ddabc2491b16fa10f
Revision: 1852
Branch: developer
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2
Revision: 1992
Branch: 3.3.0-rc
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3746
Last Changed Date: 2018-03-27 10:47:02.000000002 +0200 ./slsDetector/slsDetector.o
>>>>>>> 7cd35f24b87501374fbaf45693a2adf16dfae3e3
Last Changed Rev: 3941
Last Changed Date: 2018-07-18 12:26:21.000000002 +0200 ./threadFiles/ThreadPool.o

View File

@ -303,13 +303,14 @@ void setMasterSlaveConfiguration(){
}
}
cprintf(BLUE, "masterflags: %d\n"
cprintf(BLUE,
"masterflags: %d\n"
"masterdefaultdelay:%d\n"
"patternphase:%d\n"
"adcphase:%d\n"
"slavepatternphase:%d\n"
"slaveadcphase:%d\n"
"rsttosw1delay:%d\n",
"rsttosw1delay:%d\n"
"startacqdelay:%d\n",
masterflags,
masterdefaultdelay,
@ -906,20 +907,15 @@ int64_t getFrames(){
int64_t setExposureTime(int64_t value){
/* time is in ns */
if (value!=-1) {
double actualvalue = value*(1E-9*CLK_FREQ);
value*=(1E-9*CLK_FREQ);
if(fabs(actualvalue-value)>= 0.5){
if(actualvalue > value)
value++;
else
value--;
}
value = (value * 1E-3 * CLK_FREQ ) + 0.5;
}
return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
return (set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
}
int64_t getExposureTime(){
return get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
return (get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
}
int64_t setGates(int64_t value){
@ -933,23 +929,15 @@ int64_t getGates(){
int64_t setPeriod(int64_t value){
/* time is in ns */
if (value!=-1) {
double actualvalue = value*(1E-9*CLK_FREQ);
value*=(1E-9*CLK_FREQ);
if(fabs(actualvalue-value)>= 0.5){
if(actualvalue > value)
value++;
else
value--;
}
value = (value * 1E-3 * CLK_FREQ ) + 0.5;
}
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
return (set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
}
int64_t getPeriod(){
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
return (get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
}
int64_t setDelay(int64_t value){
@ -959,16 +947,10 @@ int64_t setDelay(int64_t value){
value += masterdefaultdelay;
cprintf(BLUE,"Actual delay for master: %lld\n", (long long int) value);
}
double actualvalue = value*(1E-9*CLK_FREQ);
value*=(1E-9*CLK_FREQ);
if(fabs(actualvalue-value)>= 0.5){
if(actualvalue > value)
value++;
else
value--;
}
value = (value * 1E-3 * CLK_FREQ ) + 0.5;
}
int64_t retval = set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
int64_t retval = (set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
if (masterflags == IS_MASTER) {
cprintf(BLUE,"Actual delay read from master: %lld\n", (long long int) retval);
retval -= masterdefaultdelay;
@ -978,7 +960,8 @@ int64_t setDelay(int64_t value){
}
int64_t getDelay(){
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
return (get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
}
int64_t setTrains(int64_t value){
@ -996,37 +979,26 @@ int64_t setProbes(int64_t value){
int64_t setProgress() {
//????? eventually call after setting the registers
return 0;
}
int64_t getProgress() {
//should be done in firmware!!!!
return 0;
}
int64_t getActualTime(){
return get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG)/(1E-9*CLK_FREQ);
return (get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG) /
(1E-3 * CLK_FREQ)) + 0.5;
}
int64_t getMeasurementTime(){
int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG);
/* u_int64_t mask=0x8000000000000000;
if (v & mask ) {
#ifdef VERBOSE
printf("no measurement time left\n");
#endif
return -1E+9;
} else*/
return v/(1E-9*CLK_FREQ);
return (v / (1E-3 * CLK_FREQ)) + 0.5;
}

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: 675d69392a6497d42b23057c7c8783c8dad768d0
Revision: 223
Branch: 3.1.0-rc
Repsitory UUID: 711e0d771edb48e77fa23d965f026add268a31ee
Revision: 235
Branch: 3.3.0-rc
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3447
Last Changed Date: 2018-02-27 14:04:08.000000002 +0100 ./server_funcs.c
Last Changed Rev: 3944
Last Changed Date: 2018-07-26 13:38:23.000000002 +0200 ./server_defs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "675d69392a6497d42b23057c7c8783c8dad768d0"
#define GITREPUUID "711e0d771edb48e77fa23d965f026add268a31ee"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3447
#define GITDATE 0x20180227
#define GITBRANCH "3.1.0-rc"
#define GITREV 0x3944
#define GITDATE 0x20180726
#define GITBRANCH "3.3.0-rc"

View File

@ -114,6 +114,28 @@ int initDetector() {
}
int setDefaultDacs() {
printf("Setting Default Dac values\n");
int ret = OK;
int i = 0;
int retval[2]={-1,-1};
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
for(i = 0; i < NDAC; ++i) {
// if not already default, set it to default
if (setDACRegister(i, -1, -1) != defaultvals[i]) {
initDACbyIndexDACU(i, defaultvals[i], 0, 0, retval);
if (abs(retval[0] - defaultvals[i])<=3) {
cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
ret = FAIL;
}
}
}
return ret;
}
int copyChannel(sls_detector_channel *destChan, sls_detector_channel *srcChan) {

View File

@ -18,6 +18,16 @@
// DAC definitions
enum dacsVal{VREF_DS, VCASCN_PB, VCASCP_PB, VOUT_CM, VCASC_OUT, VIN_CM, VREF_COMP, IB_TESTC,HIGH_VOLTAGE, CONFGAIN};
#define DEFAULT_DAC_VALS { \
660, /* VREF_DS */ \
650, /* VCASCN_PB */ \
1480, /* VCASCP_PB */ \
1520, /* VOUT_CM */ \
1320, /* VCASC_OUT */ \
1350, /* VIN_CM */ \
350, /* VREF_COMP */ \
2001 /* IB_TESTC */ \
};
/* DAC adresses */
#define DACCS {0,0,1,1,2,2,3,3,4,4,5,5,6,6}
@ -84,6 +94,7 @@ enum adcVals{TEMP_FPGA, TEMP_ADC};
void showbits(int h);
int initDetector();
int setDefaultDacs();
int copyChannel(sls_detector_channel *destChan, sls_detector_channel *srcChan);
int copyChip(sls_detector_chip *destChip, sls_detector_chip *srcChip);
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);

View File

@ -54,7 +54,7 @@
#define DEBUGOUT
#endif
#define CLK_FREQ 32.1E+6
#define CLK_FREQ 32.007729
#endif

View File

@ -11,6 +11,7 @@
#include "registers_g.h"
#include "gitInfoGotthard.h"
#include "AD9257.h" // include "commonServerFunctions.h"
#include "versionAPI.h"
#define FIFO_DATA_REG_OFF 0x50<<11
#define CONTROL_REG 0x24<<11
@ -87,9 +88,10 @@ int init_detector( int b) {
setPhaseShiftOnce();
configureADC();
setADC(-1); //already does setdaqreg and clean fifo
setSettings(GET_SETTINGS,-1);
setSettings(DYNAMICGAIN,-1);
setDefaultDacs();
//Initialization
//Initialization
setFrames(1);
setTrains(1);
setExposureTime(1e6);
@ -195,6 +197,7 @@ int function_table() {
flist[F_CLEANUP_ACQUISITION]=&stop_receiver;
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
flist[F_WRITE_ADC_REG]=&write_adc_register;
flist[F_CHECK_VERSION]= &check_version;
return OK;
}
@ -591,6 +594,8 @@ int get_id(int file_des) {
case DETECTOR_SOFTWARE_VERSION:
retval = (GITDATE & 0xFFFFFF);
break;
case CLIENT_SOFTWARE_API_VERSION:
return APIGOTTHARD;
default:
printf("Required unknown id %d \n", arg);
ret=FAIL;
@ -1660,19 +1665,43 @@ int set_settings(int file_des) {
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else {
#ifdef MCB_FUNCS
retval=setSettings(arg[0],imod);
#endif
switch(isett) {
case GET_SETTINGS:
case UNINITIALIZED:
case DYNAMICGAIN:
case HIGHGAIN:
case LOWGAIN:
case MEDIUMGAIN:
case VERYHIGHGAIN:
break;
default:
ret = FAIL;
sprintf(mess,"Setting (%d) is not implemented for this detector.\n"
"Options are dynamicgain, highgain, lowgain, mediumgain and "
"veryhighgain.\n", isett);
cprintf(RED, "Warning: %s", mess);
break;
}
if (ret != FAIL) {
retval=setSettings(isett,imod);
#ifdef VERBOSE
printf("Settings changed to %d\n",retval);
#endif
if (retval==isett || isett<0) {
ret=OK;
} else {
ret=FAIL;
printf("Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval);
}
printf("Settings changed to %d\n",retval);
#endif
if (retval != isett && isett >= 0) {
ret=FAIL;
sprintf(mess, "Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval);
printf("Warning: %s",mess);
}
else {
ret = setDefaultDacs();
if (ret == FAIL) {
strcpy(mess,"Could change settings, but could not set to default dacs\n");
cprintf(RED, "Warning: %s", mess);
}
}
}
#endif
}
if (ret==OK && differentClients==1)
ret=FORCE_UPDATE;
@ -3117,3 +3146,67 @@ int write_adc_register(int file_des) {
}
int check_version(int file_des) {
int ret=OK,ret1=OK;
int n=0;
sprintf(mess,"check version failed\n");
// receive arguments
int64_t arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT64);
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
// execute action
if (ret == OK) {
#ifdef VERBOSE
printf("Checking versioning compatibility with value %d\n",arg);
#endif
int64_t client_requiredVersion = arg;
int64_t det_apiVersion = APIGOTTHARD;
int64_t det_version = (GITDATE & 0xFFFFFF);
// old client
if (det_apiVersion > client_requiredVersion) {
ret = FAIL;
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);
cprintf(RED, "Warning: %s", mess);
}
// old software
else if (client_requiredVersion > det_version) {
ret = FAIL;
sprintf(mess,"Detector SW Version: (0x%llx). "
"Client's detector SW API Version: (0x%llx). "
"Incompatible, update detector software!\n",
det_version, client_requiredVersion);
cprintf(RED, "Warning: %s", mess);
}
}
// 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

@ -95,5 +95,5 @@ int calibrate_pedestal(int);
int set_roi(int);
int write_adc_register(int);
int check_version(int);
#endif

View File

@ -0,0 +1,7 @@
SRCFILE=gitInfoGotthard.h
DSTFILE=versionAPI.h
SRCPATTERN=GITDATE
DSTPATTERN=APIGOTTHARD
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE

View File

@ -0,0 +1 @@
../commonFiles/versionAPI.h

View File

@ -1,6 +1,6 @@
CC = gcc
CFLAGS += -Wall -DJUNGFRAUD -DVIRTUAL -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lstdc++
LDLIBS += -lm -lstdc++ -pthread
PROGS = jungfrauDetectorServer_virtual
DESTDIR ?= bin

View File

@ -75,8 +75,8 @@
#define TIME_FROM_START_MSB_REG (0x11 << MEM_MAP_SHIFT)
/* Get Delay 64 bit register */
#define GET_DELAY_LSB_REG (0x12 << MEM_MAP_SHIFT)
#define GET_DELAY_MSB_REG (0x13 << MEM_MAP_SHIFT)
#define GET_DELAY_LSB_REG (0x12 << MEM_MAP_SHIFT) // different kind of delay
#define GET_DELAY_MSB_REG (0x13 << MEM_MAP_SHIFT) // different kind of delay
/* Get Cycles 64 bit register */
#define GET_CYCLES_LSB_REG (0x14 << MEM_MAP_SHIFT)
@ -297,7 +297,35 @@
/** DAQ Register */
#define DAQ_REG (0x5D << MEM_MAP_SHIFT) //TBD in firmware
#define DAQ_REG (0x5D << MEM_MAP_SHIFT)
#define DAQ_SETTINGS_MSK (DAQ_HIGH_GAIN_MSK | DAQ_FIX_GAIN_MSK | DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_HIGH_GAIN_OFST (0)
#define DAQ_HIGH_GAIN_MSK (0x00000001 << DAQ_HIGH_GAIN_OFST)
#define DAQ_FIX_GAIN_DYNMC_VAL ((0x0 << DAQ_HIGH_GAIN_OFST) & DAQ_HIGH_GAIN_MSK)
#define DAQ_FIX_GAIN_HIGHGAIN_VAL ((0x1 << DAQ_HIGH_GAIN_OFST) & DAQ_HIGH_GAIN_MSK)
#define DAQ_FIX_GAIN_OFST (1)
#define DAQ_FIX_GAIN_MSK (0x00000003 << DAQ_FIX_GAIN_OFST)
#define DAQ_FIX_GAIN_STG_1_VAL ((0x1 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
#define DAQ_FIX_GAIN_STG_2_VAL ((0x3 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
#define DAQ_CMP_RST_OFST (4)
#define DAQ_CMP_RST_MSK (0x00000001 << DAQ_CMP_RST_OFST)
#define DAQ_STRG_CELL_SLCT_OFST (8)
#define DAQ_STRG_CELL_SLCT_MSK (0x0000000F << DAQ_STRG_CELL_SLCT_OFST)
#define DAQ_FRCE_SWTCH_GAIN_OFST (12)
#define DAQ_FRCE_SWTCH_GAIN_MSK (0x00000003 << DAQ_FRCE_SWTCH_GAIN_OFST)
#define DAQ_FRCE_GAIN_STG_1_VAL ((0x1 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_FRCE_GAIN_STG_2_VAL ((0x3 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_ELCTRN_CLLCTN_MDE_OFST (14)
#define DAQ_ELCTRN_CLLCTN_MDE_MSK (0x00000001 << DAQ_ELCTRN_CLLCTN_MDE_OFST)
#define DAQ_G2_CNNT_OFST (15)
#define DAQ_G2_CNNT_MSK (0x00000001 << DAQ_G2_CNNT_OFST)
#define DAQ_CRRNT_SRC_ENBL_OFST (16)
#define DAQ_CRRNT_SRC_ENBL_MSK (0x00000001 << DAQ_CRRNT_SRC_ENBL_OFST)
#define DAQ_CRRNT_SRC_CLMN_FIX_OFST (17)
#define DAQ_CRRNT_SRC_CLMN_FIX_MSK (0x00000001 << DAQ_CRRNT_SRC_CLMN_FIX_OFST)
#define DAQ_CRRNT_SRC_CLMN_SLCT_OFST (20)
#define DAQ_CRRNT_SRC_CLMN_SLCT_MSK (0x0000003F << DAQ_CRRNT_SRC_CLMN_SLCT_OFST)
/** Chip Power Register */
#define CHIP_POWER_REG (0x5E << MEM_MAP_SHIFT)
@ -321,8 +349,8 @@
/* Set Delay 64 bit register */
#define SET_DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT)
#define SET_DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT)
#define SET_DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT) // different kind of delay
#define SET_DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT) // different kind of delay
/* Set Cycles 64 bit register */
#define SET_CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
@ -345,7 +373,7 @@
#define SET_TRIGGER_DELAY_MSB_REG (0x71 << MEM_MAP_SHIFT)
/* Module Coordinates Register 0 */
#define COORD_0 (0x7C << MEM_MAP_SHIFT)
#define COORD_0_REG (0x7C << MEM_MAP_SHIFT)
#define COORD_0_Y_OFST (0)
#define COORD_0_Y_MSK (0x0000FFFF << COORD_0_Y_OFST)
@ -353,18 +381,20 @@
#define COORD_0_X_MSK (0x0000FFFF << COORD_0_X_OFST)
/* Module Coordinates Register 1 */
#define COORD_1 (0x7D << MEM_MAP_SHIFT)
#define COORD_1_REG (0x7D << MEM_MAP_SHIFT)
#define COORD_0_Z_OFST (0)
#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST)
/* ASIC Control Register */
#define ASIC_CTRL_REG (0x7F)
#define ASIC_CTRL_REG (0x7F << MEM_MAP_SHIFT)
#define ASIC_CTRL_PRCHRG_TMR_OFST (0)
#define ASIC_CTRL_PRCHRG_TMR_MSK (0x000000FF << ASIC_CTRL_PRCHRG_TMR_OFST)
#define ASIC_CTRL_PRCHRG_TMR_VAL ((0x1F << ASIC_CTRL_PRCHRG_TMR_OFST) & ASIC_CTRL_PRCHRG_TMR_MSK)
#define ASIC_CTRL_DS_TMR_OFST (8)
#define ASIC_CTRL_DS_TMR_MSK (0x000000FF << ASIC_CTRL_DS_TMR_OFST)
#define ASIC_CTRL_DS_TMR_VAL ((0x1F << ASIC_CTRL_DS_TMR_OFST) & ASIC_CTRL_DS_TMR_MSK)
#endif //REGISTERS_G_H

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: da010a03d725b6f18020d2142d58771534414274
Revision: 135
Repsitory UUID: 3b6ead77836f2b6d2a795a9a994259d1dc8c131d
Revision: 159
Branch: developer
Last Changed Author: Erik_Frojdh
Last Changed Rev: 3751
Last Changed Date: 2018-04-03 16:29:40.000000002 +0200 ./RegisterDefs.h
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3943
Last Changed Date: 2018-07-17 16:15:43.000000002 +0200 ./RegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "da010a03d725b6f18020d2142d58771534414274"
#define GITAUTH "Erik_Frojdh"
#define GITREV 0x3751
#define GITDATE 0x20180403
#define GITREPUUID "3b6ead77836f2b6d2a795a9a994259d1dc8c131d"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3943
#define GITDATE 0x20180717
#define GITBRANCH "developer"

View File

@ -3,11 +3,14 @@
#include "slsDetectorFunctionList.h"
#include "gitInfoJungfrau.h"
#include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h"
#include "programfpga.h"
#include "versionAPI.h"
#ifdef VIRTUAL
#include <pthread.h>
#include <time.h>
#endif
/* global variables */
//jungfrau doesnt require chips and chans (save memory)
sls_detector_module *detectorModules=NULL;
@ -21,10 +24,28 @@ int highvoltage = 0;
int dacValues[NDAC];
int32_t clkPhase[2] = {0, 0};
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
int virtual_status = 0;
int virtual_stop = 0;
#endif
/* basic tests */
int firmware_compatibility = OK;
int firmware_check_done = 0;
char firmware_message[MAX_STR_LENGTH];
int isFirmwareCheckDone() {
return firmware_check_done;
}
int getFirmwareCheckResult(char** mess) {
*mess = firmware_message;
return firmware_compatibility;
}
void checkFirmwareCompatibility(int flag) {
#ifdef VIRTUAL
cprintf(BLUE,"\n\n"
@ -32,23 +53,36 @@ void checkFirmwareCompatibility(int flag) {
"************** Jungfrau Virtual Server *****************\n"
"********************************************************\n\n");
if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE);
strcpy(firmware_message,
"FATAL ERROR: Could not map to memory. Dangerous to continue.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
}
firmware_check_done = 1;
return;
#endif
defineGPIOpins();
resetFPGA();
if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE);
strcpy(firmware_message,
"FATAL ERROR: Could not map to memory. Dangerous to continue.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
}
// does check only if flag is 0 (by default), set by command line
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE);
strcpy(firmware_message,
"FATAL ERROR: Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
}
uint16_t hversion = getHardwareVersionNumber();
@ -58,6 +92,9 @@ void checkFirmwareCompatibility(int flag) {
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
int64_t sw_fw_apiversion = 0;
int64_t client_sw_apiversion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
cprintf(BLUE,"\n\n"
@ -74,43 +111,64 @@ void checkFirmwareCompatibility(int flag) {
"Software Version:\t\t 0x%llx\n"
"F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"\n"
"********************************************************\n",
hversion, hsnumber,
ipadd, macadd,
fwversion, swversion,
sw_fw_apiversion, REQRD_FRMWR_VRSN
ipadd,
(long long unsigned int)macadd,
(long long int)fwversion,
(long long int)swversion,
(long long int)sw_fw_apiversion,
REQRD_FRMWR_VRSN,
(long long int)client_sw_apiversion
);
// return if flag is not zero, debug mode
if (flag)
return;
if (flag) {
firmware_check_done = 1;
return;
}
//cant read versions
printf("Testing Firmware-software compatibility ...\n");
if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(EXIT_FAILURE);
strcpy(firmware_message,
"FATAL ERROR: Cant read versions from FPGA. Please update firmware.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
}
//check for API compatibility - old server
if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
"Please update it to be compatible with this firmware\n\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(EXIT_FAILURE);
sprintf(firmware_message,
"FATAL ERROR: This detector software software version (0x%llx) is incompatible.\n"
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion,
(long long int)REQRD_FRMWR_VRSN);
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
}
//check for firmware compatibility - old firmware
if( REQRD_FRMWR_VRSN > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
"Please update it to v%d to be compatible with this server\n\n", REQRD_FRMWR_VRSN);
cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(EXIT_FAILURE);
sprintf(firmware_message,
"FATAL ERROR: This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with this server.\n",
(long long int)fwversion,
(long long int)REQRD_FRMWR_VRSN);
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
}
printf("Compatibility - success\n");
firmware_check_done = 1;
}
@ -155,18 +213,21 @@ int testBus() {
printf("\nTesting Bus...\n");
int ret = OK;
u_int32_t addr = SET_DELAY_LSB_REG;
u_int32_t addr = SET_TRIGGER_DELAY_LSB_REG;
int times = 1000 * 1000;
int i = 0;
for (i = 0; i < times; ++i) {
bus_w(addr, i * 100);
if (i * 100 != bus_r(SET_DELAY_LSB_REG)) {
cprintf(RED,"ERROR: Mismatch! Wrote 0x%x, read 0x%x\n", i * 100, bus_r(SET_DELAY_LSB_REG));
if (i * 100 != bus_r(addr)) {
cprintf(RED,"ERROR: Mismatch! Wrote 0x%x, read 0x%x\n",
i * 100, bus_r(addr));
ret = FAIL;
}
}
bus_w(addr, 0);
if (ret == OK)
printf("Successfully tested bus %d times\n", times);
return ret;
@ -211,6 +272,8 @@ int64_t getDetectorId(enum idMode arg){
return getFirmwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION:
return (GITDATE & 0xFFFFFF);
case CLIENT_SOFTWARE_API_VERSION:
return APIJUNGFRAU;
default:
return retval;
}
@ -254,7 +317,7 @@ u_int32_t getDetectorNumber(){
u_int64_t getDetectorMAC() {
#ifdef VIRTUAL
return 0;
#endif
#else
char output[255],mac[255]="";
u_int64_t res=0;
FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
@ -269,6 +332,7 @@ u_int64_t getDetectorMAC() {
}
sscanf(mac,"%llx",&res);
return res;
#endif
}
u_int32_t getDetectorIP(){
@ -356,6 +420,13 @@ void allocateDetectorStructureMemory(){
(detectorModules)->offset=0;
(detectorModules)->reg=0;
thisSettings = UNINITIALIZED;
{ // initialize to -1
int i = 0;
for (i = 0; i < NDAC; ++i) {
dacValues[i] = -1;
}
}
}
@ -377,22 +448,16 @@ void setupDetector() {
initDac(8); //only for old board compatibility
//set dacs
printf("Setting Default Dac values\n");
{
int i = 0;
int retval[2]={-1,-1};
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
for(i = 0; i < NDAC; ++i) {
setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval);
if (retval[0] != defaultvals[i])
cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
}
}
bus_w(DAQ_REG, 0x0); /* Only once at server startup */
setSpeed(CLOCK_DIVIDER, HALF_SPEED);
cleanFifos(); /* todo might work without */
resetCore(); /* todo might work without */
setDefaultDacs();
bus_w(DAQ_REG, 0x0); /* Only once at server startup */
setSpeed(CLOCK_DIVIDER, HALF_SPEED);
cleanFifos();
resetCore();
configureASICTimer();
bus_w(ADC_PORT_INVERT_REG, ADC_PORT_INVERT_VAL);
//Initialization of acquistion parameters
setSettings(DEFAULT_SETTINGS,-1);
@ -402,6 +467,8 @@ void setupDetector() {
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
setTimer(STORAGE_CELL_NUMBER, DEFAULT_NUM_STRG_CLLS);
selectStoragecellStart(DEFAULT_STRG_CLL_STRT);
/*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/
setTiming(DEFAULT_TIMING_MODE);
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
@ -411,10 +478,31 @@ void setupDetector() {
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
// reset temp event
setTemperatureEvent(0);
}
int setDefaultDacs() {
int ret = OK;
printf("Setting Default Dac values\n");
{
int i = 0;
int retval[2]={-1,-1};
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
for(i = 0; i < NDAC; ++i) {
// if not already default, set it to default
if (dacValues[i] != defaultvals[i]) {
setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval);
if (retval[0] != defaultvals[i]) {
cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
ret = FAIL;
}
}
}
}
return ret;
}
@ -433,9 +521,9 @@ int powerChip (int on){
}
}
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
/* temporary setup until new firmware fixes bug */
//return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
//return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
/**temporary fix until power reg status can be read */
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
}
@ -501,7 +589,11 @@ int getPhase() {
return clkPhase[0];
}
void configureASICTimer() {
printf("\nConfiguring ASIC Timer\n");
bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_PRCHRG_TMR_MSK) | ASIC_CTRL_PRCHRG_TMR_VAL);
bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_DS_TMR_MSK) | ASIC_CTRL_DS_TMR_VAL);
}
@ -623,6 +715,15 @@ int setSpeed(enum speedVariable arg, int val) {
/* parameters - timer */
int selectStoragecellStart(int pos) {
if (pos >= 0) {
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_STRG_CELL_SLCT_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | ((pos << DAQ_STRG_CELL_SLCT_OFST) & DAQ_STRG_CELL_SLCT_MSK));
}
return ((bus_r(DAQ_REG) & DAQ_STRG_CELL_SLCT_MSK) >> DAQ_STRG_CELL_SLCT_OFST);
}
int64_t setTimer(enum timerIndex ind, int64_t val) {
@ -640,8 +741,10 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
if(val >= 0){
printf("\nSetting exptime: %lldns\n", (long long int)val);
val *= (1E-3 * CLK_RUN);
val -= ACQ_TIME_MIN_CLOCK;
if(val < 0) val = 0;
}
retval = set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) / (1E-3 * CLK_RUN);
retval = (set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) + ACQ_TIME_MIN_CLOCK) / (1E-3 * CLK_RUN);
printf("Getting exptime: %lldns\n", (long long int)retval);
break;
@ -670,6 +773,16 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
printf("Getting #cycles: %lld\n", (long long int)retval);
break;
case STORAGE_CELL_NUMBER:
if(val >= 0) {
printf("\nSetting #storage cells to %lld\n", (long long int)val);
bus_w(CONTROL_REG, (bus_r(CONTROL_REG) & ~CONTROL_STORAGE_CELL_NUM_MSK) |
((val << CONTROL_STORAGE_CELL_NUM_OFST) & CONTROL_STORAGE_CELL_NUM_MSK));
}
retval = ((bus_r(CONTROL_REG) & CONTROL_STORAGE_CELL_NUM_MSK) >> CONTROL_STORAGE_CELL_NUM_OFST);
printf("Getting #storage cells: %lld\n", (long long int)retval);
break;
default:
cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind);
break;
@ -697,12 +810,12 @@ int64_t getTimeLeft(enum timerIndex ind){
retval = get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) / (1E-3 * CLK_SYNC);
printf("Getting period left: %lldns\n", (long long int)retval);
break;
/*
case DELAY_AFTER_TRIGGER:
retval = get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
retval = get64BitReg(xxx) / (1E-3 * CLK_SYNC);
printf("Getting delay left: %lldns\n", (long long int)retval);
break;
*/
case CYCLES_NUMBER:
retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
printf("Getting number of cycles left: %lld\n", (long long int)retval);
@ -781,38 +894,46 @@ int getModule(sls_detector_module *myMod){
enum detectorSettings setSettings(enum detectorSettings sett, int imod){
if(sett == UNINITIALIZED){
if(sett == UNINITIALIZED)
return thisSettings;
}
uint32_t val = -1;
const int defaultIndex[NUM_SETTINGS] = DEFAULT_SETT_INDX;
const int defaultvals[NUM_SETTINGS] = DEFAULT_SETT_VALS;
const char defaultNames[NUM_SETTINGS][100]=DEFAULT_SETT_NAMES;
// set settings
if(sett != GET_SETTINGS) {
switch (sett) {
case DYNAMICGAIN:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
printf("\nConfigured settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG));
break;
case DYNAMICHG0:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
printf("\nConfigured settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n", bus_r(DAQ_REG));
break;
case FIXGAIN1:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_1_VAL);
printf("\nConfigured settings - Fix Gain 1, DAQ Reg: 0x%x\n", bus_r(DAQ_REG));
break;
case FIXGAIN2:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_2_VAL);
printf("\nConfigured settings - Fix Gain 2, DAQ Reg: 0x%x\n", bus_r(DAQ_REG));
break;
case FORCESWITCHG1:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_1_VAL);
printf("\nConfigured settings - Force Switch Gain 1, DAQ Reg: 0x%x\n", bus_r(DAQ_REG));
break;
case FORCESWITCHG2:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_2_VAL);
printf("\nConfigured settings - Force Switch Gain 2, DAQ Reg: 0x%x\n", bus_r(DAQ_REG));
break;
default:
cprintf(RED, "Error: This settings is not defined for this detector %d\n", (int)sett);
return -1;
}
// find gain val
{
int i;
for (i = 0; i < NUM_SETTINGS; ++i) {
if (sett == defaultIndex[i]) {
val = defaultvals[i];
break;
}
}
//not found
if (val == -1) {
cprintf(RED, "Error: This settings is not defined for this detector %d\n", (int)sett);
return val;
}
printf("\nConfiguring to settings %s (%d)\n"
" Writing to DAQ Register with val:0x%x\n", defaultNames[i], sett, val);
}
bus_w(DAQ_REG, val);
thisSettings = sett;
}
@ -823,35 +944,39 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
enum detectorSettings getSettings(){
enum detectorSettings sett = -1;
const int defaultIndex[NUM_SETTINGS] = DEFAULT_SETT_INDX;
const int defaultvals[NUM_SETTINGS] = DEFAULT_SETT_VALS;
const char defaultNames[NUM_SETTINGS][100]=DEFAULT_SETT_NAMES;
uint32_t val = bus_r(DAQ_REG);
uint32_t val = bus_r(DAQ_REG) & DAQ_SETTINGS_MSK;
printf("\nGetting Settings\n Reading DAQ Register :0x%x\n", val);
//find setting
{
int i;
for (i = 0; i < NUM_SETTINGS; ++i) {
if (val == defaultvals[i]) {
sett = defaultIndex[i];
break;
}
}
//not found
if (sett == -1) {
cprintf(RED, "Error: Undefined settings read for this detector (DAQ Reg val: 0x%x)\n", val);
thisSettings = UNDEFINED;
return sett;
}
thisSettings = sett;
printf("Settings Read: %s (%d)\n", defaultNames[i], thisSettings);
switch(val) {
case DAQ_FIX_GAIN_DYNMC_VAL:
thisSettings = DYNAMICGAIN;
printf("Settings read: DYNAMICGAIN\n");
break;
case DAQ_FIX_GAIN_HIGHGAIN_VAL:
thisSettings = DYNAMICHG0;
printf("Settings read: DYNAMICHG0\n");
break;
case DAQ_FIX_GAIN_STG_1_VAL:
thisSettings = FIXGAIN1;
printf("Settings read: FIXGAIN1\n");
break;
case DAQ_FIX_GAIN_STG_2_VAL:
thisSettings = FIXGAIN2;
printf("Settings read: FIXGAIN2\n");
break;
case DAQ_FRCE_GAIN_STG_1_VAL:
thisSettings = FORCESWITCHG1;
printf("Settings read: FORCESWITCHG1\n");
break;
case DAQ_FRCE_GAIN_STG_2_VAL:
thisSettings = FORCESWITCHG2;
printf("Settings read: FORCESWITCHG2\n");
break;
default:
thisSettings = UNDEFINED;
printf("Settings read: Undefined. Value read:0x%x\n", val);
}
return thisSettings;
}
@ -1115,7 +1240,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
(unsigned int)((sourcemac>>16)&0xFF),
(unsigned int)((sourcemac>>8)&0xFF),
(unsigned int)((sourcemac>>0)&0xFF),
sourcemac);
(long long unsigned int)sourcemac);
printf("Source Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport);
printf("Dest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip);
@ -1126,7 +1251,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
(unsigned int)((destmac>>16)&0xFF),
(unsigned int)((destmac>>8)&0xFF),
(unsigned int)((destmac>>0)&0xFF),
destmac);
(long long unsigned int)destmac);
printf("Dest. Port : %d \t\t\t(0x%08x)\n",udpport, udpport);
long int checksum=calcChecksum(sourceip, destip);
@ -1188,16 +1313,16 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
int setDetectorPosition(int pos[]) {
int ret = OK;
bus_w(COORD_0, bus_r(COORD_0) | ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK));
if ((bus_r(COORD_0) & COORD_0_X_MSK) != ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK))
bus_w(COORD_0_REG, bus_r(COORD_0_REG) | ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK));
if ((bus_r(COORD_0_REG) & COORD_0_X_MSK) != ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK))
ret = FAIL;
bus_w(COORD_0, bus_r(COORD_0) | ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK));
if ((bus_r(COORD_0) & COORD_0_Y_MSK) != ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK))
bus_w(COORD_0_REG, bus_r(COORD_0_REG) | ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK));
if ((bus_r(COORD_0_REG) & COORD_0_Y_MSK) != ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK))
ret = FAIL;
bus_w(COORD_1, bus_r(COORD_1) | ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK));
if ((bus_r(COORD_1) & COORD_0_Z_MSK) != ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK))
bus_w(COORD_1_REG, bus_r(COORD_1_REG) | ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK));
if ((bus_r(COORD_1_REG) & COORD_0_Z_MSK) != ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK))
ret = FAIL;
if (ret == OK)
@ -1371,7 +1496,15 @@ int setNetworkParameter(enum NETWORKINDEX mode, int value) {
int startStateMachine(){
#ifdef VIRTUAL
return OK;
virtual_status = 1;
virtual_stop = 0;
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
virtual_status = 0;
cprintf(RED,"Could not start Virtual acquisition thread\n");
return FAIL;
}
cprintf(GREEN,"***Virtual Acquisition started\n");
return OK;
#endif
printf("*******Starting State Machine*******\n");
@ -1386,12 +1519,30 @@ int startStateMachine(){
}
int stopStateMachine(){
#ifdef VIRTUAL
return OK;
#endif
cprintf(BG_RED,"*******Stopping State Machine*******\n");
void* start_timer(void* arg) {
int wait_in_s = (setTimer(FRAME_NUMBER, -1) *
setTimer(CYCLES_NUMBER, -1) *
(setTimer(STORAGE_CELL_NUMBER, -1) + 1) *
(setTimer(FRAME_PERIOD, -1)/(1E9)));
cprintf(GREEN,"going to wait for %d s\n", wait_in_s);
while(!virtual_stop && (wait_in_s >= 0)) {
usleep(1000 * 1000);
wait_in_s--;
}
cprintf(GREEN,"Virtual Timer Done***\n");
virtual_status = 0;
return NULL;
}
#endif
int stopStateMachine(){
cprintf(BG_RED,"*******Stopping State Machine*******\n");
#ifdef VIRTUAL
virtual_stop = 0;
return OK;
#endif
//stop state machine
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STOP_ACQ_MSK);
usleep(100);
@ -1407,7 +1558,13 @@ int stopStateMachine(){
enum runStatus getRunStatus(){
#ifdef VIRTUAL
return IDLE;
if(virtual_status == 0){
printf("Status: IDLE\n");
return IDLE;
}else{
printf("Status: RUNNING...\n");
return RUNNING;
}
#endif
#ifdef VERBOSE
printf("Getting status\n");
@ -1453,9 +1610,13 @@ enum runStatus getRunStatus(){
void readFrame(int *ret, char *mess){
#ifdef VIRTUAL
*ret = (int)FAIL;
sprintf(mess,"virtual detector, no acquisition taken\n");
return;
while(virtual_status) {
//cprintf(RED,"Waiting for finished flag\n");
usleep(5000);
}
*ret = (int)FINISHED;
strcpy(mess,"acquisition successfully finished\n");
return;
#endif
// wait for status to be done
while(runBusy()){
@ -1466,7 +1627,7 @@ void readFrame(int *ret, char *mess){
int64_t retval = getTimeLeft(FRAME_NUMBER) + 1;
if ( retval > 0) {
*ret = (int)FAIL;
sprintf(mess,"no data and run stopped: %lld frames left\n",retval);
sprintf(mess,"no data and run stopped: %lld frames left\n",(long long int)retval);
cprintf(RED,"%s\n",mess);
} else {
*ret = (int)FINISHED;
@ -1479,7 +1640,7 @@ void readFrame(int *ret, char *mess){
u_int32_t runBusy(void) {
#ifdef VIRTUAL
return 0;
return virtual_status;
#endif
u_int32_t s = ((bus_r(STATUS_REG) & RUN_BUSY_MSK) >> RUN_BUSY_OFST);
#ifdef VERBOSE

View File

@ -8,8 +8,9 @@
#define GOODBYE (-200)
#define PROGRAMMING_MODE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWR_VRSN 0x171220
#define REQRD_FRMWR_VRSN 0x180226
/* Struct Definitions */
@ -40,22 +41,6 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
420 /* VREF_COMP */ \
};
#define NUM_SETTINGS 6
#define DEFAULT_SETT_INDX {DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2};
#define DEFAULT_SETT_VALS { 0x0f00, /* DYNAMICGAIN */ \
0x0f01, /* DYNAMICHG0 */ \
0x0f02, /* FIXGAIN1 */ \
0x0f06, /* FIXGAIN2 */ \
0x1f00, /* FORCESWITCHG1 */ \
0x3f00 /* FORCESWITCHG2 */ \
};
#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
"Dynamic High Gain 0", /* DYNAMICHG0 */ \
"Fix Gain 1", /* FIXGAIN1 */ \
"Fix Gain 2", /* FIXGAIN2 */ \
"Force Switch Gain 1", /* FORCESWITCHG1*/ \
"Force Switch Gain 2" /* FORCESWITCHG2*/ \
};
enum NETWORKINDEX { TXN_FRAME };
@ -87,22 +72,27 @@ enum NETWORKINDEX { TXN_FRAME };
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_TMP_THRSHLD (65*1000) //milli degree Celsius
#define DEFAULT_NUM_STRG_CLLS (0)
#define DEFAULT_STRG_CLL_STRT (0xf)
/* Defines in the Firmware */
#define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define MAX_TIMESLOT_VAL (0x1F)
#define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees
#define MAX_STORAGE_CELL_VAL (15) //0xF
#define ACQ_TIME_MIN_CLOCK (2)
#define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */
#define SAMPLE_ADC_QUARTER_SPEED (SAMPLE_DECMT_FACTOR_4_VAL + SAMPLE_DGTL_SAMPLE_8_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x2810 */
#define CONFIG_HALF_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define CONFIG_QUARTER_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f)
#define ADC_PHASE_HALF_SPEED (0x48) //72
#define ADC_PHASE_QUARTER_SPEED (0x48) //72
#define ADC_OFST_HALF_SPEED_VAL (0x1f) //(0x20)
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f) //(0x0f)
#define ADC_PHASE_HALF_SPEED (0x2D) //45
#define ADC_PHASE_QUARTER_SPEED (0x2D) //45
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
/* Maybe not required for jungfrau */
#define NTRIMBITS (6)

View File

@ -0,0 +1,7 @@
SRCFILE=gitInfoJungfrau.h
DSTFILE=versionAPI.h
SRCPATTERN=GITDATE
DSTPATTERN=APIJUNGFRAU
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE

View File

@ -0,0 +1 @@
../commonFiles/versionAPI.h

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,11 @@
#include "multiSlsDetector.h"
#include "multiSlsDetectorCommand.h"
#include "sls_detector_exceptions.h"
#include <stdlib.h>
using namespace std;
int dummyCallback(detectorData* d, int p,void*) {
cout << "got data " << p << endl;
@ -16,83 +17,136 @@ int dummyCallback(detectorData* d, int p,void*) {
class multiSlsDetectorClient {
public:
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \
string answer; \
multiSlsDetectorCommand *myCmd; \
int id=-1, iv=0, pos=-1; \
int del=0; \
char cmd[100]; \
if (action==slsDetectorDefs::READOUT_ACTION) { \
public:
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \
string answer; \
multiSlsDetectorCommand *myCmd; \
int id = -1, pos = -1, iv = 0; \
bool verify = true, update = true; \
int del = 0; \
char cmd[100] = ""; \
if (argc!=0) {
iv=sscanf(argv[0],"%d-%s",&id,cmd); \
if (iv>0 && id>=0 && strchr(argv[0],'-')) {
cout << "id " << id << endl; \
if (iv>1)
argv[0]=cmd;
}
iv=sscanf(argv[0],"%d:",&pos); \
if (iv>0 && pos>=0 && strchr(argv[0],':'))
cout << "pos " << pos << "is not allowed!" << endl; \
}
if (id<0)
id=0;
if (action==slsDetectorDefs::PUT_ACTION && argc<2) { \
cout << "Wrong usage - should be: "<< argv[0] << \
"[id-][pos:]channel arg" << endl; \
cout << endl; \
return; \
if (del) delete myDetector; \
}; \
if (action==slsDetectorDefs::GET_ACTION && argc<1) { \
cout << "Wrong usage - should be: "<< argv[0] << \
"[id-][pos:]channel arg" << endl; \
cout << endl; \
if (del) delete myDetector; \
return; \
}; \
if (myDetector==NULL) { \
myDetector=new multiSlsDetector(id); \
//myDetector->registerDataCallback(&dummyCallback, NULL);
del=1; \
};
// cout << "noid" <<endl;
myCmd=new multiSlsDetectorCommand(myDetector); \
answer=myCmd->executeLine(argc, argv, action); \
cout << answer<< endl; \
delete myCmd; \
if (del) delete myDetector; \
return; \
}; \
if (action==slsDetectorDefs::PUT_ACTION && argc<2) { \
cout << "Wrong usage - should be: "<< argv[0] << \
"[id-][pos:]channel arg" << endl; \
cout << endl; \
return; \
if (del) delete myDetector; \
};
if (action==slsDetectorDefs::GET_ACTION && argc<1) { \
cout << "Wrong usage - should be: "<< argv[0] << \
"[id-][pos:]channel arg" << endl; \
cout << endl; \
if (del) delete myDetector; \
return; \
}; \
if (myDetector==NULL) { \
iv=sscanf(argv[0],"%d-%s",&id, cmd); \
if (iv==2 && id>=0) { \
myDetector=new multiSlsDetector(id); \
argv[0]=cmd; \
cout << id << "-" ; \
} else { \
myDetector=new multiSlsDetector(); \
}; \
del=1; \
} \
iv=sscanf(argv[0],"%d:%s",&pos, cmd); \
if (iv==2 && pos>=0) { \
argv[0]=cmd; \
cout << pos << ":" ; \
} ; \
myCmd=new multiSlsDetectorCommand(myDetector); \
answer=myCmd->executeLine(argc, argv, action, pos); \
cout << argv[0] << " " ; \
cout << answer<< endl; \
delete myCmd; \
if (del) delete myDetector; \
};
if (action==slsDetectorDefs::READOUT_ACTION) { \
id = 0; \
pos = -1; \
if (argc) { \
// multi id scanned
if (strchr(argv[0],'-')) { \
iv=sscanf(argv[0],"%d-%s",&id, cmd); \
//%s needn't be there (if not 1:), so 1 or 2 arguments scanned
if (iv >= 1 && id >= 0) { \
argv[0] = cmd; \
cout << id << "-" ; \
} else { \
id = 0; \
} \
} \
// single id scanned
if (strchr(argv[0],':')) { \
iv=sscanf(argv[0],"%d:",&pos); \
if (iv == 1 && pos >= 0) { \
cout << "pos " << pos << " is not allowed for readout!" << endl; \
return; \
} \
} \
} \
} else { \
// multi id scanned
iv=sscanf(argv[0],"%d-%s",&id, cmd); \
// scan success
if (iv == 2 && id >= 0) { \
argv[0] = cmd; \
cout << id << "-" ; \
} else { \
id = 0; \
} \
// sls pos scanned
iv=sscanf(argv[0],"%d:%s", &pos, cmd); \
// scan success
if (iv == 2 && pos >= 0) { \
argv[0] = cmd; \
cout << pos << ":" ; \
} \
if (iv != 2) { \
pos = -1; \
} \
// remove the %d- and %d:
if (!strlen(cmd)) { \
strcpy(cmd, argv[0]); \
} \
// special commands
string scmd = cmd; \
// free without calling multiSlsDetector constructor
if (scmd == "free") { \
if (pos != -1) \
slsDetector::freeSharedMemory(id, pos); \
else \
multiSlsDetector::freeSharedMemory(id); \
return; \
} \
// get user details without verify sharedMultiSlsDetector version
else if ((scmd == "user") && (action==slsDetectorDefs::GET_ACTION)) { \
verify = false; \
update = false; \
myDetector=NULL; \
} \
} \
//cout<<"id:"<<id<<" pos:"<<pos<<endl;
// create multiSlsDetector class if required
if (myDetector==NULL) { \
try { \
myDetector = new multiSlsDetector(id, verify, update); \
} catch (const SharedMemoryException & e) { \
cout << e.GetMessage() << endl; \
return; \
} catch (...) { \
cout << " caught exception" << endl; \
return; \
} \
del=1; \
} \
// call multi detector command line
myCmd=new multiSlsDetectorCommand(myDetector); \
try { \
answer=myCmd->executeLine(argc, argv, action, pos); \
} catch (const SharedMemoryException & e) { \
cout << e.GetMessage() << endl; \
delete myCmd; \
if (del) delete myDetector; \
return; \
} catch (...) { \
cout << " caught exception" << endl; \
delete myCmd; \
if (del) delete myDetector; \
return; \
} \
if (action!=slsDetectorDefs::READOUT_ACTION) { \
cout << argv[0] << " " ; \
} \
cout << answer<< endl; \
delete myCmd; \
if (del) delete myDetector; \
};
};

View File

@ -6,7 +6,7 @@
#include "slsDetector.h"
#include "multiSlsDetector.h"
#include "slsDetectorCommand.h"
using namespace std;
/** @short This class handles the command line I/Os, help etc. of the text clients */
@ -27,7 +27,7 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* \returns answer string */
/* *\/ */
string executeLine(int narg, char *args[], int action, int id=-1) { \
string s; \
if (id>=0) {
@ -37,14 +37,14 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
s=cmd->executeLine(narg, args, action); \
if(d->getErrorMask()) \
myDet->setErrorMask((myDet->getErrorMask())|(1<<id)); \
delete cmd;
delete cmd;
} else
s=string("detector does no exist"); \
} else \
s=slsDetectorCommand::executeLine(narg,args,action); \
return s;
return s;
};
/**
* calls executeLine with PUT_ACTION
*/

View File

@ -0,0 +1,171 @@
#include "SharedMemory.h"
#include "sls_detector_exceptions.h"
#include "ansi.h"
#include <iostream>
#include <stdio.h> // printf
#include <cerrno> // errno
#include <cstring> // strerror
#include <unistd.h>
#include <fcntl.h> // O_CREAT, O_TRUNC..
#include <sys/stat.h> // fstat
#include <sys/mman.h> // shared memory
#include <sstream>
#include "stdlib.h"
#define SHM_MULTI_PREFIX "/slsDetectorPackage_multi_"
#define SHM_SLS_PREFIX "_sls_"
#define SHM_ENV_NAME "SLSDETNAME"
SharedMemory::SharedMemory(int multiId, int slsId):
fd(-1),
shmSize(0)
{
name = ConstructSharedMemoryName(multiId, slsId);
}
SharedMemory::~SharedMemory(){
if (fd >= 0)
close(fd);
}
bool SharedMemory::IsExisting() {
bool ret = true;
int tempfd = shm_open(name.c_str(), O_RDWR, 0);
if ((tempfd < 0) && (errno == ENOENT)) {
ret = false;
}
close(tempfd);
return ret;
}
std::string SharedMemory::GetName() {
return name;
}
void* SharedMemory::CreateSharedMemory(size_t sz){
// create
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
if (fd < 0) {
cprintf(RED, "Error: Create shared memory %s failed: %s\n",
name.c_str(), strerror(errno));
throw SharedMemoryException();
}
// resize
if (ftruncate(fd, sz) < 0) {
cprintf(RED, "Error: Create shared memory %s failed at ftruncate: %s\n",
name.c_str(), strerror(errno));
close(fd);
throw SharedMemoryException();
}
// map
void* addr = MapSharedMemory(sz);
printf("Shared memory created %s \n", name.c_str());
return addr;
}
void* SharedMemory::OpenSharedMemory(size_t sz){
// open
fd = shm_open(name.c_str(), O_RDWR, 0);
if (fd < 0) {
cprintf(RED, "Error: Open existing shared memory %s failed: %s\n",
name.c_str(), strerror(errno));
throw SharedMemoryException();
}
return MapSharedMemory(sz);
}
void SharedMemory::UnmapSharedMemory(void* addr) {
if (munmap(addr, shmSize) < 0) {
cprintf(RED, "Error: Unmapping shared memory %s failed: %s\n",
name.c_str(), strerror(errno));
close(fd);
throw SharedMemoryException();
}
}
void SharedMemory::RemoveSharedMemory() {
if (shm_unlink(name.c_str()) < 0) {
// silent exit if shm did not exist anyway
if (errno == ENOENT)
return;
cprintf(RED, "Error: Free Shared Memory %s Failed: %s\n",
name.c_str(), strerror(errno));
throw SharedMemoryException();
}
printf("Shared memory deleted %s \n", name.c_str());
}
void* SharedMemory::MapSharedMemory(size_t sz) {
void* addr = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (addr == MAP_FAILED) {
cprintf(RED, "Error: Mapping shared memory %s failed: %s\n",
name.c_str(), strerror(errno));
close(fd);
throw SharedMemoryException();
}
shmSize = sz;
close(fd);
return addr;
}
std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) {
// using environment path
string sEnvPath = "";
char* envpath = getenv(SHM_ENV_NAME);
if (envpath != NULL) {
sEnvPath.assign(envpath);
sEnvPath.insert(0,"_");
}
stringstream ss;
if (slsId < 0)
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
else
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId << sEnvPath;
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));
throw SharedMemoryException();
}
return temp;
}
int SharedMemory::VerifySizeMatch(size_t expectedSize) {
struct stat sb;
// could not fstat
if (fstat(fd, &sb) < 0) {
cprintf(RED, "Error: Could not verify existing shared memory %s size match "
"(could not fstat): %s\n", name.c_str(), strerror(errno));
close(fd);
throw SharedMemoryException();
}
//size does not match
long unsigned int sz = (long unsigned int)sb.st_size;
if (sz != expectedSize) {
cprintf(RED, "Warning: Existing shared memory %s size does not match.\n",
name.c_str());
#ifdef VERBOSE
cprintf(RED, " Expected %ld, found %ld\n", expectedSize, sz);
#endif
throw SharedMemoryException();
return 1;
}
return 0;
}

View File

@ -0,0 +1,105 @@
#pragma once
/************************************************
* @file SharedMemory.h
* @short functions basic implemenation of
* shared memory
***********************************************/
/**
*@short functions basic implemenation of shared memory
*/
#include <iostream>
#include <string>
class SharedMemory{
public:
/**
* Constructor
* creates the single/multi detector shared memory name
* @param multiId multi detector id
* @param slsId sls detector id, -1 if a multi detector shared memory
*/
SharedMemory(int multiId, int slsId);
/**
* Destructor
*/
~SharedMemory();
/**
* Verify if it exists
* @param name of shared memory
* @return true if exists, else false
*/
bool IsExisting();
/**
* Get shared memory name
*/
std::string GetName();
/**
* Create Shared memory and call MapSharedMemory to map it to an address
* throws a SharedMemoryException exception on failure to create, ftruncate or map
* @param sz of shared memory
*/
void* CreateSharedMemory(size_t sz);
/**
* Open existing Shared memory and call MapSharedMemory to map it to an address
* throws a SharedMemoryException exception on failure to open or map
* @param sz of shared memory
*/
void* OpenSharedMemory(size_t sz);
/**
* Unmap shared memory from an address
* throws a SharedMemoryException exception on failure
* @param addr double pointer to address to be mapped
*/
void UnmapSharedMemory(void* addr);
/**
* Remove existing Shared memory
*/
void RemoveSharedMemory();
/**
* Maximum length of name as from man pages
*/
static const int NAME_MAX = 255;
private:
/**
* Create Shared memory name
* throws exception if name created is longer than required 255(manpages)
* @param multiId multi detector id
* @param slsId sls detector id, -1 if a multi detector shared memory
* @returns shared memory name
*/
std::string ConstructSharedMemoryName(int multiId, int slsId);
/**
* Map shared memory to an address
* throws a SharedMemoryException exception on failure
* @param sz of shared memory
*/
void* MapSharedMemory(size_t sz);
/**
* Verify if existing shared memory size matches expected size
* @param expectedSize expected size of shared memory, replaced with smaller size if size does not match
* @return 0 for success, 1 for fail
*/
int VerifySizeMatch(size_t expectedSize);
/** Shared memory name */
std::string name;
/** File descriptor */
int fd;
/** shm size */
size_t shmSize;
};

View File

@ -1,8 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "b8bdbf4da61f95b88893b02ddabc2491b16fa10f"
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3746
#define GITDATE 0x20180327
#define GITBRANCH "developer"
#define GITREV 0x3941
#define GITDATE 0x20180718
#define GITBRANCH "3.3.0-rc"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
#include <fstream>
using namespace std;
//
/**
@ -38,7 +38,7 @@ class slsDetectorActions : public virtual slsDetectorBase
\param par for script
\returns 0 if action disabled, >0 otherwise
*/
int setAction(int iaction, string fname="", string par="");
int setAction(int iaction,std::string fname="",std::string par="");
/**
set action script
@ -46,7 +46,7 @@ class slsDetectorActions : public virtual slsDetectorBase
\param fname for script ("" disable)
\returns 0 if action disabled, >0 otherwise
*/
int setActionScript(int iaction, string fname="");
int setActionScript(int iaction, std::string fname="");
/**
@ -55,7 +55,7 @@ class slsDetectorActions : public virtual slsDetectorBase
\param par for script
\returns 0 if action disabled, >0 otherwise
*/
int setActionParameter(int iaction, string par="");
int setActionParameter(int iaction, std::string par="");
/**
@ -63,14 +63,14 @@ class slsDetectorActions : public virtual slsDetectorBase
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action script
*/
string getActionScript(int iaction);
std::string getActionScript(int iaction);
/**
returns action parameter
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action parameter
*/
string getActionParameter(int iaction);
std::string getActionParameter(int iaction);
/**
returns action mode
@ -89,20 +89,20 @@ class slsDetectorActions : public virtual slsDetectorBase
\param precision to write the scan varaible in the scan name (-1 unchanged)
\returns 0 is scan disabled, >0 otherwise
*/
int setScan(int index, string script="", int nvalues=-1, double *values=NULL, string par="", int precision=-1);
int setScan(int index, std::string script="", int nvalues=-1, double *values=NULL, std::string par="", int precision=-1);
/** set scan script
\param index of the scan (0,1)
\param script fname for script ("" disables, "none" disables and overwrites current, "threshold" threshold scan, "trimbits", trimbits scan)
\returns 0 is scan disabled, >0 otherwise
*/
int setScanScript(int index, string script="");
int setScanScript(int index, std::string script="");
/** set scan script parameter
\param index of the scan (0,1)
\param script parameter for scan
\returns 0 is scan disabled, >0 otherwise
*/
int setScanParameter(int index, string par="");
int setScanParameter(int index, std::string par="");
/** set scan script parameter
\param index of the scan (0,1)
\param precision scan varaible precision to be printed in file name
@ -130,14 +130,14 @@ class slsDetectorActions : public virtual slsDetectorBase
\param iscan can be (0,1)
\returns scan script
*/
string getScanScript(int iscan);
std::string getScanScript(int iscan);
/**
returns scan parameter
\param iscan can be (0,1)
\returns scan parameter
*/
string getScanParameter(int iscan);
std::string getScanParameter(int iscan);
/**
returns scan mode
@ -273,7 +273,7 @@ class slsDetectorActions : public virtual slsDetectorBase
int startIndex;
int lastIndex;
int nowIndex;
string fName;
std::string fName;

View File

@ -54,8 +54,6 @@
#include <string>
using namespace std;
/**
@libdoc The slsDetectorBase contains also a set of purely virtual functions useful for the implementation of the derived classes
@ -83,7 +81,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
*/
virtual detectorType getDetectorsType(int pos=-1)=0;
string getDetectorDeveloper(){return string("PSI");};
std::string getDetectorDeveloper(){return std::string("PSI");};
// protected:
/**
@ -91,14 +89,14 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param fname file with angular conversion constants ("" disable)
\returns 0 if angular conversion disabled, >0 otherwise
*/
virtual int setAngularConversionFile(string fname="")=0;
virtual int setAngularConversionFile(std::string fname="")=0;
/**
pure virtual function
returns the angular conversion file
*/
virtual string getAngularConversionFile()=0;
virtual std::string getAngularConversionFile()=0;
@ -108,7 +106,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param fname for script ("" disable)
\returns 0 if action disabled, >0 otherwise
*/
virtual int setActionScript(int iaction, string fname="")=0;
virtual int setActionScript(int iaction, std::string fname="")=0;
/**
set action
@ -116,21 +114,21 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param par for script ("" disable)
\returns 0 if action disabled, >0 otherwise
*/
virtual int setActionParameter(int iaction, string par="")=0;
virtual int setActionParameter(int iaction, std::string par="")=0;
/**
returns action script
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action script
*/
virtual string getActionScript(int iaction)=0;
virtual std::string getActionScript(int iaction)=0;
/**
returns action parameter
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action parameter
*/
virtual string getActionParameter(int iaction)=0;
virtual std::string getActionParameter(int iaction)=0;
/**
set scan script
@ -138,7 +136,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan)
\returns 0 if scan disabled, >0 otherwise
*/
virtual int setScanScript(int index, string script="")=0;
virtual int setScanScript(int index, std::string script="")=0;
/**
set scan script parameter
@ -146,7 +144,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param spar parameter to be passed to the scan script with syntax par=spar
\returns 0 if scan disabled, >0 otherwise
*/
virtual int setScanParameter(int index, string spar="")=0;
virtual int setScanParameter(int index, std::string spar="")=0;
/** set scan precision
@ -169,14 +167,14 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param index is the scan index (0 or 1)
\returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name
*/
virtual string getScanScript(int index)=0;
virtual std::string getScanScript(int index)=0;
/**
get scan script
\param index is the scan index (0 or 1)
\returns scan script parameter
*/
virtual string getScanParameter(int index)=0;
virtual std::string getScanParameter(int index)=0;
/**
get scan precision
@ -199,7 +197,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param fname file name
\returns OK or FAIL
*/
virtual int writeConfigurationFile(string const fname)=0;
virtual int writeConfigurationFile(std::string const fname)=0;
/**
@ -208,7 +206,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param fname file name to load data from
\returns OK or FAIL
*/
virtual int loadImageToDetector(imageType index,string const fname)=0;
virtual int loadImageToDetector(imageType index,std::string const fname)=0;
/**
\returns number of positions
@ -241,7 +239,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual int getTotalNumberOfChannels(dimension d)=0;
/** generates file name without extension */
virtual string createFileName()=0;
virtual std::string createFileName()=0;
virtual void incrementProgress()=0;
@ -254,12 +252,12 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual double* decodeData(int *datain, int &nn, double *fdata=NULL)=0;
virtual string getCurrentFileName()=0;
virtual std::string getCurrentFileName()=0;
virtual int getFileIndexFromFileName(string fname)=0;
virtual int getFileIndexFromFileName(std::string fname)=0;
virtual int getIndicesFromFileName(string fname,int &index)=0;
virtual int getIndicesFromFileName(std::string fname,int &index)=0;
virtual double *convertAngles()=0;
/**
@ -282,9 +280,9 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
*/
virtual int getRateCorrection()=0;
virtual int setFlatFieldCorrection(string fname="")=0;
virtual int setFlatFieldCorrection(std::string fname="")=0;
int setFlatFieldCorrectionFile(string fname=""){return setFlatFieldCorrection(fname);};
int setFlatFieldCorrectionFile(std::string fname=""){return setFlatFieldCorrection(fname);};
/**
set/get dynamic range
@ -369,16 +367,18 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
set/get timer value
\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)
*/
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
int64_t setExposureTime(int64_t t=-1){return setTimer(ACQUISITION_TIME,t);};
int64_t setSubFrameExposureTime(int64_t t=-1){return setTimer(SUBFRAME_ACQUISITION_TIME,t);};
int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);};
int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);};
int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);};
int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);};
int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
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 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);};
int64_t setNumberOfFrames(int64_t t=-1, int imod = -1){return setTimer(FRAME_NUMBER,t,imod);};
int64_t setNumberOfCycles(int64_t t=-1, int imod = -1){return setTimer(CYCLES_NUMBER,t,imod);};
/** sets/gets the value of important readout speed parameters
@ -406,6 +406,15 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
} \
};
void setOverflowMode(int value){ \
if(value>=0){ \
switch(value){ \
case 1: setReadOutFlags(SHOW_OVERFLOW);break; \
case 0: setReadOutFlags(NOOVERFLOW);break; \
} \
} \
};
/**
get readout mode of detector (eiger specific)
\returns 0 for nonparallel, 1 for parallel, 2 for safe
@ -416,6 +425,18 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
if (ret&PARALLEL) return 1; \
if (ret&SAFE) return 2; \
return -1; \
}
/**
get readout overflow mode of detector (eiger specific)
\returns 1 for show overflow, 0 for do not show overflow
*/
int getOverflowMode(){ \
int ret = setReadOutFlags(); \
if (ret&SHOW_OVERFLOW) return 1; \
if (ret&NOOVERFLOW) return 0; \
return -1; \
} \
/**
@ -496,6 +517,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
int setThresholdEnergy(int e_ev, int tb, int isettings, int id){return setThresholdEnergy(e_ev, id, (detectorSettings)isettings, tb);}
/**
@ -509,12 +531,12 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\param fname file name
\returns OK or FAIL
*/
virtual int readConfigurationFile(string const fname)=0;
virtual int readConfigurationFile(std::string const fname)=0;
virtual int dumpDetectorSetup(string const fname, int level)=0;
int dumpDetectorSetup(string const fname){return dumpDetectorSetup(fname,0);};
virtual int retrieveDetectorSetup(string const fname, int level)=0;
int retrieveDetectorSetup(string const fname){return retrieveDetectorSetup(fname,0);};
virtual int dumpDetectorSetup(std::string const fname, int level)=0;
int dumpDetectorSetup(std::string const fname){return dumpDetectorSetup(fname,0);};
virtual int retrieveDetectorSetup(std::string const fname, int level)=0;
int retrieveDetectorSetup(std::string const fname){return retrieveDetectorSetup(fname,0);};
/**
@short
\returns the default output file index
@ -576,6 +598,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
*/
virtual void readFrameFromReceiver()=0;
/**
* Enable data streaming to client
* @param enable 0 to disable, 1 to enable, -1 to get the value
@ -604,29 +627,29 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
virtual runStatus startReceiverReadout()=0;
/** returns detector type string from detector type index
\param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
/** returns detector type std::string from detector type index
\param t std::string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
\returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, MÖNCH, GENERIC
*/
static string getDetectorType(detectorType t){\
static std::string getDetectorType(detectorType t){\
switch (t) {\
case MYTHEN: return string("Mythen"); \
case PILATUS: return string("Pilatus"); \
case EIGER: return string("Eiger"); \
case GOTTHARD: return string("Gotthard"); \
case AGIPD: return string("Agipd"); \
case MOENCH: return string("Moench"); \
case JUNGFRAU: return string("Jungfrau"); \
case JUNGFRAUCTB: return string("JungfrauCTB"); \
case PROPIX: return string("Propix"); \
default: return string("Unknown"); \
case MYTHEN: return std::string("Mythen"); \
case PILATUS: return std::string("Pilatus"); \
case EIGER: return std::string("Eiger"); \
case GOTTHARD: return std::string("Gotthard"); \
case AGIPD: return std::string("Agipd"); \
case MOENCH: return std::string("Moench"); \
case JUNGFRAU: return std::string("Jungfrau"); \
case JUNGFRAUCTB: return std::string("JungfrauCTB"); \
case PROPIX: return std::string("Propix"); \
default: return std::string("Unknown"); \
}};
/** returns detector type index from detector type string
/** returns detector type index from detector type std::string
\param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
\returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Mönch, Unknown
*/
static detectorType getDetectorType(string const type){\
static detectorType getDetectorType(std::string const type){\
if (type=="Mythen") return MYTHEN;\
if (type=="Pilatus") return PILATUS; \
if (type=="Eiger") return EIGER; \
@ -640,11 +663,11 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
/** returns synchronization type index from string
/** returns synchronization type index from std::string
\param type can be none, gating, trigger, complementary
\returns ONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
*/
static synchronizationMode getSyncType(string const type){\
static synchronizationMode getSyncType(std::string const type){\
if (type=="none") return NO_SYNCHRONIZATION;\
if (type=="gating") return MASTER_GATES;\
if (type=="trigger") return MASTER_TRIGGERS; \
@ -652,55 +675,55 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
return GET_SYNCHRONIZATION_MODE; \
};
/** returns synchronization type string from index
/** returns synchronization type std::string from index
\param s can be NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
\returns none, gating, trigger, complementary, unknown
*/
static string getSyncType(synchronizationMode s ){\
static std::string getSyncType(synchronizationMode s ){\
switch(s) { \
case NO_SYNCHRONIZATION: return string("none"); \
case MASTER_GATES: return string("gating"); \
case MASTER_TRIGGERS: return string("trigger"); \
case SLAVE_STARTS_WHEN_MASTER_STOPS: return string("complementary"); \
default: return string("unknown"); \
case NO_SYNCHRONIZATION: return std::string("none"); \
case MASTER_GATES: return std::string("gating"); \
case MASTER_TRIGGERS: return std::string("trigger"); \
case SLAVE_STARTS_WHEN_MASTER_STOPS: return std::string("complementary"); \
default: return std::string("unknown"); \
}};
/** returns string from external signal type index
/** returns std::string from external signal type index
\param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG
\returns string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
\returns std::string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
*/
static string externalSignalType(externalSignalFlag f){\
static std::string externalSignalType(externalSignalFlag f){\
switch(f) { \
case SIGNAL_OFF: return string( "off"); \
case GATE_IN_ACTIVE_HIGH: return string( "gate_in_active_high"); \
case GATE_IN_ACTIVE_LOW: return string( "gate_in_active_low"); \
case TRIGGER_IN_RISING_EDGE: return string( "trigger_in_rising_edge"); \
case TRIGGER_IN_FALLING_EDGE: return string( "trigger_in_falling_edge"); \
case RO_TRIGGER_IN_RISING_EDGE: return string( "ro_trigger_in_rising_edge"); \
case RO_TRIGGER_IN_FALLING_EDGE: return string( "ro_trigger_in_falling_edge"); \
case GATE_OUT_ACTIVE_HIGH: return string( "gate_out_active_high"); \
case GATE_OUT_ACTIVE_LOW: return string( "gate_out_active_low"); \
case TRIGGER_OUT_RISING_EDGE: return string( "trigger_out_rising_edge"); \
case TRIGGER_OUT_FALLING_EDGE: return string( "trigger_out_falling_edge"); \
case RO_TRIGGER_OUT_RISING_EDGE: return string( "ro_trigger_out_rising_edge"); \
case RO_TRIGGER_OUT_FALLING_EDGE: return string( "ro_trigger_out_falling_edge"); \
case MASTER_SLAVE_SYNCHRONIZATION: return string("sync"); \
case OUTPUT_LOW: return string("gnd"); \
case OUTPUT_HIGH: return string("vcc"); \
default: return string( "unknown"); \
case SIGNAL_OFF: return std::string( "off"); \
case GATE_IN_ACTIVE_HIGH: return std::string( "gate_in_active_high"); \
case GATE_IN_ACTIVE_LOW: return std::string( "gate_in_active_low"); \
case TRIGGER_IN_RISING_EDGE: return std::string( "trigger_in_rising_edge"); \
case TRIGGER_IN_FALLING_EDGE: return std::string( "trigger_in_falling_edge"); \
case RO_TRIGGER_IN_RISING_EDGE: return std::string( "ro_trigger_in_rising_edge"); \
case RO_TRIGGER_IN_FALLING_EDGE: return std::string( "ro_trigger_in_falling_edge"); \
case GATE_OUT_ACTIVE_HIGH: return std::string( "gate_out_active_high"); \
case GATE_OUT_ACTIVE_LOW: return std::string( "gate_out_active_low"); \
case TRIGGER_OUT_RISING_EDGE: return std::string( "trigger_out_rising_edge"); \
case TRIGGER_OUT_FALLING_EDGE: return std::string( "trigger_out_falling_edge"); \
case RO_TRIGGER_OUT_RISING_EDGE: return std::string( "ro_trigger_out_rising_edge"); \
case RO_TRIGGER_OUT_FALLING_EDGE: return std::string( "ro_trigger_out_falling_edge"); \
case MASTER_SLAVE_SYNCHRONIZATION: return std::string("sync"); \
case OUTPUT_LOW: return std::string("gnd"); \
case OUTPUT_HIGH: return std::string("vcc"); \
default: return std::string( "unknown"); \
} };
/** returns external signal type index from string
/** returns external signal type index from std::string
\param sval off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
\returns can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown)
*/
static externalSignalFlag externalSignalType(string sval){\
static externalSignalFlag externalSignalType(std::string sval){\
if (sval=="off") return SIGNAL_OFF;\
if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \
if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\
@ -719,39 +742,39 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns detector settings string from index
/** returns detector settings std::string from index
\param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, GET_SETTINGS
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, verylowgain, undefined
*/
static string getDetectorSettings(detectorSettings s){\
static std::string getDetectorSettings(detectorSettings s){\
switch(s) { \
case STANDARD: return string("standard"); \
case FAST: return string("fast"); \
case HIGHGAIN: return string("highgain"); \
case DYNAMICGAIN: return string("dynamicgain"); \
case LOWGAIN: return string("lowgain"); \
case MEDIUMGAIN: return string("mediumgain"); \
case VERYHIGHGAIN: return string("veryhighgain"); \
case LOWNOISE: return string("lownoise"); \
case DYNAMICHG0: return string("dynamichg0"); \
case FIXGAIN1: return string("fixgain1"); \
case FIXGAIN2: return string("fixgain2"); \
case FORCESWITCHG1: return string("forceswitchg1");\
case FORCESWITCHG2: return string("forceswitchg2");\
case VERYLOWGAIN: return string("verylowgain");\
default: return string("undefined"); \
case STANDARD: return std::string("standard"); \
case FAST: return std::string("fast"); \
case HIGHGAIN: return std::string("highgain"); \
case DYNAMICGAIN: return std::string("dynamicgain"); \
case LOWGAIN: return std::string("lowgain"); \
case MEDIUMGAIN: return std::string("mediumgain"); \
case VERYHIGHGAIN: return std::string("veryhighgain"); \
case LOWNOISE: return std::string("lownoise"); \
case DYNAMICHG0: return std::string("dynamichg0"); \
case FIXGAIN1: return std::string("fixgain1"); \
case FIXGAIN2: return std::string("fixgain2"); \
case FORCESWITCHG1: return std::string("forceswitchg1");\
case FORCESWITCHG2: return std::string("forceswitchg2");\
case VERYLOWGAIN: return std::string("verylowgain");\
default: return std::string("undefined"); \
}};
/** returns detector settings string from index
/** returns detector settings std::string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, undefined
\returns setting index STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN,LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERYLOWGAIN, GET_SETTINGS
*/
static detectorSettings getDetectorSettings(string s){ \
static detectorSettings getDetectorSettings(std::string s){ \
if (s=="standard") return STANDARD; \
if (s=="fast") return FAST; \
if (s=="highgain") return HIGHGAIN; \
@ -771,31 +794,31 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
/**
returns external communication mode string from index
returns external communication mode std::string from index
\param f can be AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, BURST_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown
*/
static string externalCommunicationType(externalCommunicationMode f){ \
static std::string externalCommunicationType(externalCommunicationMode f){ \
switch(f) { \
case AUTO_TIMING: return string( "auto"); \
case TRIGGER_EXPOSURE: return string("trigger"); \
case TRIGGER_READOUT: return string("ro_trigger"); \
case GATE_FIX_NUMBER: return string("gating"); \
case GATE_WITH_START_TRIGGER: return string("triggered_gating"); \
case BURST_TRIGGER: return string("burst_trigger"); \
default: return string( "unknown"); \
case AUTO_TIMING: return std::string( "auto"); \
case TRIGGER_EXPOSURE: return std::string("trigger"); \
case TRIGGER_READOUT: return std::string("ro_trigger"); \
case GATE_FIX_NUMBER: return std::string("gating"); \
case GATE_WITH_START_TRIGGER: return std::string("triggered_gating"); \
case BURST_TRIGGER: return std::string("burst_trigger"); \
default: return std::string( "unknown"); \
} };
/**
returns external communication mode index from string
returns external communication mode index from std::string
\param sval can be auto, trigger, ro_trigger, gating, triggered_gating
\returns AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, BURST_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
*/
static externalCommunicationMode externalCommunicationType(string sval){\
static externalCommunicationMode externalCommunicationType(std::string sval){\
if (sval=="auto") return AUTO_TIMING;\
if (sval=="trigger") return TRIGGER_EXPOSURE; \
if (sval=="ro_trigger") return TRIGGER_READOUT;\
@ -805,64 +828,66 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
return GET_EXTERNAL_COMMUNICATION_MODE; \
};
/** returns string from run status index
/** returns std::string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED
\returns string error, waiting, running, data, finished
\returns std::string error, waiting, running, data, finished
*/
static string runStatusType(runStatus s){\
static std::string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return string("error"); \
case WAITING: return string("waiting"); \
case RUNNING: return string("running");\
case TRANSMITTING: return string("data"); \
case RUN_FINISHED: return string("finished"); \
default: return string("idle"); \
case ERROR: return std::string("error"); \
case WAITING: return std::string("waiting"); \
case RUNNING: return std::string("running");\
case TRANSMITTING: return std::string("data"); \
case RUN_FINISHED: return std::string("finished"); \
default: return std::string("idle"); \
}};
/** returns string from file format index
/** returns std::string from file format index
\param s can be RAW, HDF5
\returns string raw, hdf5
\returns std::string raw, hdf5
*/
static string fileFormats(fileFormat f){\
static std::string fileFormats(fileFormat f){\
switch (f) { \
case BINARY: return string("binary"); \
case ASCII: return string("ascii"); \
case HDF5: return string("hdf5"); \
default: return string("unknown"); \
case BINARY: return std::string("binary"); \
case ASCII: return std::string("ascii"); \
case HDF5: return std::string("hdf5"); \
default: return std::string("unknown"); \
}};
/** returns 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
\returns 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
/** 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
*/
static string getTimerType(timerIndex t){ \
static std::string getTimerType(timerIndex t){ \
switch (t) { \
case FRAME_NUMBER: return string("frame_number"); \
case ACQUISITION_TIME: return string("acquisition_time"); \
case FRAME_PERIOD: return string("frame_period"); \
case DELAY_AFTER_TRIGGER: return string("delay_after_trigger"); \
case GATES_NUMBER: return string("gates_number"); \
case PROBES_NUMBER: return string("probes_number"); \
case CYCLES_NUMBER: return string("cycles_number"); \
case ACTUAL_TIME: return string("actual_time"); \
case MEASUREMENT_TIME: return string("measurement_time"); \
case PROGRESS: return string("progress"); \
case MEASUREMENTS_NUMBER: return string("measurements_number"); \
case FRAMES_FROM_START: return string("frames_from_start"); \
case FRAMES_FROM_START_PG: return string("frames_from_start_pg"); \
case SAMPLES_JCTB: return string("samples_jctb"); \
case SUBFRAME_ACQUISITION_TIME: return string("subframe_acquisition_time"); \
default: return string("unknown"); \
case FRAME_NUMBER: return std::string("frame_number"); \
case ACQUISITION_TIME: return std::string("acquisition_time"); \
case FRAME_PERIOD: return std::string("frame_period"); \
case DELAY_AFTER_TRIGGER: return std::string("delay_after_trigger"); \
case GATES_NUMBER: return std::string("gates_number"); \
case PROBES_NUMBER: return std::string("probes_number"); \
case CYCLES_NUMBER: return std::string("cycles_number"); \
case ACTUAL_TIME: return std::string("actual_time"); \
case MEASUREMENT_TIME: return std::string("measurement_time"); \
case PROGRESS: return std::string("progress"); \
case MEASUREMENTS_NUMBER: return std::string("measurements_number"); \
case FRAMES_FROM_START: return std::string("frames_from_start"); \
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 STORAGE_CELL_NUMBER: return std::string("storage_cell_number"); \
default: return std::string("unknown"); \
}};
/**
@short returns adc index from string
@short returns adc index from std::string
\param s can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr
\returns TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, TEMPERATURE_DCDC, TEMPERATURE_SODL,
TEMPERATURE_SODR, TEMPERATURE_FPGA2, TEMPERATURE_FPGA3, -1 when unknown mode
*/
static int getADCIndex(string s){
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;
@ -876,11 +901,11 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
/**
@short returns dac index from string
@short returns dac index from std::string
\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(string s){
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;

View File

@ -6,6 +6,8 @@
#include <cstdlib>
#include <iomanip>
using namespace std;
/*! \mainpage Introduction
This program is intended to control the SLS detectors via command line interface.
@ -262,38 +264,31 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
/*! \page config
- \b add Adds a detector at the end of the multi-detector structure. \c put argument is the hostname or IP adress. Returns the chained list of detector hostnames.
*/
descrToFuncMap[i].m_pFuncName="add";//OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdd;
++i;
/*! \page config
- <b>remove i</b> Removes controller \c i from the multi-detector structure. Can be used for partial readout of the detector.
*/
descrToFuncMap[i].m_pFuncName="remove";//OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRemove;
++i;
/*! \page config
- <b>type</b> Sets/gets detector type. \c Returns \c (string). Normally not used. Using hostname is enough.
*/
descrToFuncMap[i].m_pFuncName="type"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdHostname;
++i;
/*! \page config
- <b>hostname</b> \c put adds the hostname (ot IP adress) at the end of the multi-detector structure. If used for a single controlled (i:) replaces the current hostname. Returns the list of the hostnames of the multi-detector structure. \c Returns \c (string)
- <b>hostname</b> \c put frees shared memory and sets the hostname (or IP adress). Only allowed at multi detector level. \c Returns the list of the hostnames of the multi-detector structure. \c (string)
*/
descrToFuncMap[i].m_pFuncName="hostname"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdHostname;
++i;
/*! \page config
- <b>id[:i]</b> Returns the id of the detector structure. i is the detector position in a multi detector system. If used a \c put, configures the id of the detector structure. i is the detector position in a multi detector system and l is the id of the detector to be added.
- \b add appends a hostname (or IP address) at the end of the multi-detector structure. Only allowed at multi detector level. Cannot get. \c Returns the current list of detector hostnames. \c (string)
*/
descrToFuncMap[i].m_pFuncName="id"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdId;
descrToFuncMap[i].m_pFuncName="add";//OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdHostname;
++i;
/*! \page config
- <b>replace</b> \c Sets the hostname (or IP adress) for a single detector. Only allowed at single detector level. Cannot get. \c Returns the hostnames for that detector \c (string)
*/
descrToFuncMap[i].m_pFuncName="replace"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdHostname;
++i;
/*! \page config
- <b>user</b> \c Returns user details from shared memory. Only allowed at multi detector level. Cannot put. \c (string)
*/
descrToFuncMap[i].m_pFuncName="user"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdUser;
++i;
/*! \page config
@ -414,7 +409,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
*/
/*! \page config
- <b>flags [flag]</b> sets/gets the readout flags to mode. Options: none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown. Used for MYTHEN and EIGER only. \c Returns \c (string). put takes one string and \c returns concatenation of all active flags separated by spaces.
- <b>flags [flag]</b> sets/gets the readout flags to mode. Options: none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overflow, nooverflow, unknown. Used for MYTHEN and EIGER only. \c Returns \c (string). put takes one string and \c returns concatenation of all active flags separated by spaces.
*/
descrToFuncMap[i].m_pFuncName="flags";
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
@ -505,6 +500,22 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
Commands to check versions of each subsystem
*/
/*! \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")
*/
descrToFuncMap[i].m_pFuncName="checkdetversion"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN;
++i;
/*! \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")
*/
descrToFuncMap[i].m_pFuncName="checkrecversion"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN;
++i;
/*! \page config
- <b>moduleversion:[i]</b> Gets the firmware version of module i. Used for MYTHEN only. Only get! \c Returns \c (long int) in hexadecimal or "undefined module number"
*/
@ -586,6 +597,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++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)
*/
descrToFuncMap[i].m_pFuncName="subperiod"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>delay [i]</b> sets/gets delay in s. Used in MYTHEN, GOTTHARD only. \c Returns \c (double with 9 decimal digits)
*/
@ -635,6 +653,20 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++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)
*/
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)
*/
descrToFuncMap[i].m_pFuncName="storagecell_start"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++i;
/* read only timers */
/*! \page timing
@ -1733,7 +1765,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
/* Acquisition actions */
/*! \page actions Actions
@ -1957,6 +1988,21 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_udpsocksize [size]</b> sets/gets the UDP socket buffer size. Already trying to set by default to 100mb, 2gb for Jungfrau. Does not remember in client shared memory, so must be initialized each time after setting receiver hostname in config file.\c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="rx_udpsocksize"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_realudpsocksize [size]</b> gets the actual UDP socket buffer size. Usually double the set udp socket buffer size due to kernel bookkeeping. Get only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="rx_realudpsocksize"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>detectormac [mac]</b> sets/gets the mac address of the detector UDP interface from where the detector will stream data. Use single-detector command. Normally unused. \c Returns \c (string)
*/
@ -2034,6 +2080,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
/*! \page network
- <b>rx_jsonaddheader [t]</b> sets/gets additional json header to be streamed out with the zmq from receiver. Default is empty. \c t must be in the format "\"label1\":\"value1\",\"label2\":\"value2\"" etc. Use only if it needs to be processed by an intermediate process. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName="rx_jsonaddheader"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
/*! \page network
- <b>configuremac [i]</b> configures the MAC of the detector with these parameters: detectorip, detectormac, rx_udpip, rx_udpmac, rx_udpport, rx_udpport2 (if applicable). This command is already included in \c rx_hsotname. Only put!. \c Returns \c (int)
*/
@ -2174,6 +2227,34 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
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_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)
*/
descrToFuncMap[i].m_pFuncName="r_discardpolicy"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_padding</b> sets/gets the frame padding in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="r_padding"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
++i;
/* pattern generator */
/*! \page ctb Chiptest board
@ -2436,7 +2517,10 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
if (action==HELP_ACTION) {
return helpAcquire(narg,args,HELP_ACTION);
}
if (!myDet->getNumberOfDetectors()) {
cprintf(RED, "Error: This shared memory has no detectors added. Aborting.\n");
return string("acquire unsuccessful");
}
myDet->setOnline(ONLINE_FLAG);
int r_online = myDet->setReceiverOnline(ONLINE_FLAG);
@ -2640,86 +2724,16 @@ string slsDetectorCommand::cmdFree(int narg, char *args[], int action) {
if (action==HELP_ACTION) {
return helpFree(narg,args,HELP_ACTION);
}
myDet->freeSharedMemory();
return("freed");
return("Error: Should have been freed before creating constructor\n");
}
string slsDetectorCommand::helpFree(int narg, char *args[], int action) {
return string("free \t frees the shared memory\n");
}
string slsDetectorCommand::cmdAdd(int narg, char *args[], int action) {
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
#endif
int ivar, ival;
string var=string(args[0]);
ostringstream os;
if (action==HELP_ACTION) {
return helpAdd(narg,args,HELP_ACTION);
} else if (action==PUT_ACTION) {
size_t p=string(args[0]).find(':');
if (p==string::npos)
ivar=-1;
else {
istringstream vvstr(var.substr(p+1));
vvstr >> ivar;
if (vvstr.fail())
ivar=-1; //append at the end
}
if (sscanf(args[1],"%d",&ival)) {
// add by detector id
os<< myDet->addSlsDetector(ival, ivar)<< endl;;
} else {
//add by hostname
os<< myDet->addSlsDetector(args[1], ivar)<< endl;
}
return os.str();
}
return string("cannot get");
}
string slsDetectorCommand::helpAdd(int narg, char *args[], int action){
return string("add[:i] det \t adds a detector in position i to the multi detector structure. i is the detector position, default is appended. det can either be the detector hostname or the detector id. Returns -1 if it fails or the total number of detectors in the multidetector structure\n");
}
string slsDetectorCommand::cmdRemove(int narg, char *args[], int action){
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
#endif
ostringstream os;
int ival;//ivar,
string var=string(args[0]);
if (action==HELP_ACTION) {
return helpRemove(narg,args,HELP_ACTION);
} else if (action==PUT_ACTION) {
if (sscanf(args[1],"%d",&ival)) {
// remove detector in position ival
os << myDet->removeSlsDetector(ival);
} else {
// remove detector by hostname
os<< myDet->removeSlsDetector(args[1]);
}
return os.str();
}
return string("cannot get");
}
string slsDetectorCommand::helpRemove(int narg, char *args[], int action){
return string("remove det \t removes a detector. det can either be the detector hostname or the detector position. Returns the total number of detectors in the multidetector structure\n");
}
string slsDetectorCommand::cmdHostname(int narg, char *args[], int action){
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
@ -2728,131 +2742,96 @@ string slsDetectorCommand::cmdHostname(int narg, char *args[], int action){
if (action==HELP_ACTION) {
return helpHostname(narg,args,HELP_ACTION);
}
ostringstream os;
int ivar=-1;//, ival;
string var=string(args[0]);
char hostname[1000];
size_t p=string(args[0]).find(':');
if (p==string::npos)
ivar=-1;
else {
istringstream vvstr(var.substr(p+1));
vvstr >> ivar;
if (vvstr.fail())
ivar=-1;
if (action==GET_ACTION) {
if ((cmd == "add") || (cmd == "replace"))
return string("cannot get");
}
p=string(args[0]).find("hostname");
if (p==string::npos) {
//type
// cout << "should add by type!" << endl;
if (action==PUT_ACTION) {
//add by type
if (ivar==-1) {
strcpy(hostname,"");
for (int id=1; id<narg; ++id) {
strcat(hostname,args[id]);
if(narg>2)
strcat(hostname,"+");
}
} else
strcpy(hostname,args[1]);
myDet->ssetDetectorsType(hostname, ivar);
if (action==PUT_ACTION) {
if (((cmd == "add") || (cmd == "hostname")) &&
(!myDet->isMultiSlsDetectorClass())) {
return string ("Wrong usage - setting hostname/add only from "
"multiDetector level");
}
return myDet->sgetDetectorsType(ivar);
} else {
if (action==PUT_ACTION) {
//add by hostname
if (ivar==-1) {
strcpy(hostname,"");
for (int id=1; id<narg; ++id) {
strcat(hostname,args[id]);
if(narg>2)
strcat(hostname,"+");
}
} else
strcpy(hostname,args[1]);
myDet->setHostname(hostname, ivar);
if ((cmd == "replace") && (myDet->isMultiSlsDetectorClass())) {
return string ("Wrong usage - replace only from "
"single detector level");
}
char hostname[1000];
strcpy(hostname,"");
// if each argument is a hostname
for (int id=1; id<narg; ++id) {
strcat(hostname,args[id]);
if(narg>2)
strcat(hostname,"+");
}
return string(myDet->getHostname(ivar));
if (cmd == "add")
myDet->addMultipleDetectors(hostname);
else
myDet->setHostname(hostname);
}
return myDet->getHostname();
}
string slsDetectorCommand::helpHostname(int narg, char *args[], int action){
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION)
os << string("hostname[:i] \t returns the hostname(s) of the detector structure. i is the detector position in a multi detector system\n");
if (action==PUT_ACTION || action==HELP_ACTION)
os << string("hostname[:i] name [name name]\t configures the hostnames of the detector structure. i is the detector position in a multi detector system\n");
if (action==GET_ACTION || action==HELP_ACTION) {
os << string("hostname \t returns the hostname(s) of the multi detector structure.\n");
os << string("add \t cannot get\n");
os << string("replace \t cannot get\n");
}
if (action==PUT_ACTION || action==HELP_ACTION) {
os << string("hostname name [name name]\t frees shared memory and "
"sets the hostname (or IP adress). Only allowed at multi detector level.\n");
os << string ("add det [det det]\t appends a hostname (or IP address) at "
"the end of the multi-detector structure. Only allowed at multi detector level."
"Returns hostnames in the multi detector structure\n");
os << string ("replace det \t Sets the hostname (or IP adress) for a "
"single detector. Only allowed at single detector level. "
"Returns the hostnames for that detector\n");
}
return os.str();
}
string slsDetectorCommand::cmdId(int narg, char *args[], int action){
string slsDetectorCommand::cmdUser(int narg, char *args[], int action){
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
#endif
if (action==HELP_ACTION) {
return helpId(narg,args,HELP_ACTION);
return helpHostname(narg,args,HELP_ACTION);
}
ostringstream os;
int ivar, ival;
string var=string(args[0]);
// char answer[1000];
size_t p=string(args[0]).find(':');
if (p==string::npos)
ivar=-1;
else {
istringstream vvstr(var.substr(p+1));
vvstr >> ivar;
if (vvstr.fail())
ivar=-1;
}
if (action==PUT_ACTION) {
//add by hostname
istringstream vvstr(args[1]);
vvstr >> ival;
if (vvstr.fail())
ival=-1;
myDet->setDetectorId(ival, ivar);
return string("cannot put");
}
os << myDet->getDetectorId(ivar);
return os.str();
if (!myDet->isMultiSlsDetectorClass()) {
return string ("Wrong usage - getting user details only from "
"multiDetector level");
}
return myDet->getUserDetails();
}
string slsDetectorCommand::helpId(int narg, char *args[], int action){
string slsDetectorCommand::helpUser(int narg, char *args[], int action){
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION)
os << string("id[:i] \t returns the id of the detector structure. i is the detector position in a multi detector system\n");
if (action==PUT_ACTION || action==HELP_ACTION)
os << string("id:i l]\t configures the id of the detector structure. i is the detector position in a multi detector system and l is the id of the detector to be added\n");
if (action==GET_ACTION || action==HELP_ACTION) {
os << string("user \t returns user details from shared memory without updating shared memory. "
"Only allowed at multi detector level.\n");
}
if (action==PUT_ACTION || action==HELP_ACTION) {
os << string("user \t cannot put\n");
}
return os.str();
}
string slsDetectorCommand::cmdMaster(int narg, char *args[], int action){
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
@ -2980,9 +2959,9 @@ string slsDetectorCommand::cmdSettingsDir(int narg, char *args[], int action){
if (action==PUT_ACTION) {
myDet->setSettingsDir(string(args[1]));
}
if (myDet->getSettingsDir()==NULL)
if (myDet->getSettingsDir()=="")
return string("undefined");
return string(myDet->getSettingsDir());
return myDet->getSettingsDir();
}
@ -3010,9 +2989,9 @@ string slsDetectorCommand::cmdCalDir(int narg, char *args[], int action){
if (action==PUT_ACTION) {
myDet->setCalDir(string(args[1]));
}
if (myDet->getCalDir()==NULL)
if ( (myDet->getCalDir()).empty() )
return string("undefined");
return string(myDet->getCalDir());
return myDet->getCalDir();
}
@ -3050,12 +3029,18 @@ string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action){
}
}
int npos=myDet->getTrimEn();
sprintf(answer,"%d",npos);
int opos[npos];
myDet->getTrimEn(opos);
for (int ip=0; ip<npos;++ip) {
sprintf(answer,"%s %d",answer,opos[ip]);
if (npos != -1) {
sprintf(answer,"%d",npos);
int opos[npos];
npos = myDet->getTrimEn(opos);
if (npos != -1) {
for (int ip=0; ip<npos;++ip) {
sprintf(answer,"%s %d",answer,opos[ip]);
}
}
}
if (npos == -1)
sprintf(answer,"%d", -1);
return string(answer);
}
@ -4043,7 +4028,18 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
} else if (cmd=="txndelay_left") {
} else if (cmd=="rx_udpsocksize") {
t=RECEIVER_UDP_SCKT_BUF_SIZE;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
} else if (cmd=="rx_realudpsocksize") {
t=RECEIVER_REAL_UDP_SCKT_BUF_SIZE;
if (action==PUT_ACTION){
return ("cannot put!");
}
} else if (cmd=="txndelay_left") {
t=DETECTOR_TXN_DELAY_LEFT;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
@ -4089,6 +4085,8 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
// if streaming, switch it off
prev_streaming = myDet->enableDataStreamingFromReceiver();
if (prev_streaming) myDet->enableDataStreamingFromReceiver(0);
} else if (cmd=="rx_jsonaddheader") {
t=ADDITIONAL_JSON_HEADER;
}
else return ("unknown network parameter")+cmd;
@ -4132,6 +4130,13 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "rx_zmqip ip \n sets/gets the 0MQ (TCP) ip of the receiver from where data is streamed from (eg. to GUI or another process for further processing). "
"Default is ip of rx_hostname and works for GUI. This is usually used to stream out to an external process for further processing."
"restarts streaming in receiver with new port" << std::endl;
os << "rx_jsonaddheader [t]\n sets additional json header to be streamed "
"out with the zmq from receiver. Default is empty. t must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
"Use only if it needs to be processed by an intermediate process." << std::endl;
os << "rx_udpsocksize [t]\n sets the UDP socket buffer size. Different defaults for Jungfrau. "
"Does not remember in client shared memory, "
"so must be initialized each time after setting receiver "
"hostname in config file." << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "detectormac \n gets detector mac "<< std::endl;
@ -4148,6 +4153,11 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "rx_zmqport \n gets the 0MQ (TCP) port of the receiver from where data is streamed from"<< std::endl;
os << "zmqip \n gets the 0MQ (TCP) ip of the client to where final data is streamed to.If no custom ip, empty until first time connect to receiver" << std::endl;
os << "rx_zmqip \n gets/gets the 0MQ (TCP) ip of the receiver from where data is streamed from. If no custom ip, empty until first time connect to receiver" << std::endl;
os << "rx_jsonaddheader \n gets additional json header to be streamed "
"out with the zmq from receiver." << std::endl;
os << "rx_udpsocksize \n gets the UDP socket buffer size." << std::endl;
os << "rx_realudpsocksize \n gets the actual UDP socket buffer size. Usually double the set udp socket buffer size due to kernel bookkeeping." << std::endl;
}
return os.str();
@ -4578,7 +4588,10 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
if (cmd=="settings") {
detectorSettings sett = GET_SETTINGS;
if (action==PUT_ACTION) {
sett = myDet->setSettings(myDet->getDetectorSettings(string(args[1])));
sett = myDet->getDetectorSettings(string(args[1]));
if (sett == -1)
return string ("unknown settings scanned " + string(args[1]));
sett = myDet->setSettings(sett);
if (myDet->getDetectorsType() == EIGER) {
return myDet->getDetectorSettings(sett);
}
@ -4626,12 +4639,16 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
#ifdef VERBOSE
std::cout<< " trimfile " << sval << std::endl;
#endif
int ret = OK;
if (action==GET_ACTION) {
//create file names
myDet->saveSettingsFile(sval, -1);
ret = myDet->saveSettingsFile(sval, -1);
} else if (action==PUT_ACTION) {
myDet->loadSettingsFile(sval,-1);
ret = myDet->loadSettingsFile(sval,-1);
}
if (ret == OK)
return sval;
else return string("not successful");
}
return myDet->getSettingsFile();
} else if (cmd=="trim") {
@ -4816,6 +4833,24 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
sprintf(answer,"0x%lx", retval);
return string(answer);
}
if (cmd=="checkdetversion") {
int retval = myDet->checkVersionCompatibility(CONTROL_PORT);
if (retval < 0)
sprintf(answer, "%d", -1);
sprintf(answer,"%s", retval == OK ? "compatible" : "incompatible");
return string(answer);
}
if (cmd=="checkrecversion") {
myDet->setReceiverOnline(ONLINE_FLAG);
int retval = myDet->checkVersionCompatibility(DATA_PORT);
if (retval < 0)
sprintf(answer, "%d", -1);
sprintf(answer,"%s", retval == OK ? "compatible" : "incompatible");
return string(answer);
}
return string("unknown id mode ")+cmd;
}
@ -4824,6 +4859,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 << "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;
@ -5593,6 +5630,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=="delay")
index=DELAY_AFTER_TRIGGER;
else if (cmd=="gates")
@ -5607,6 +5646,19 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
index=MEASUREMENTS_NUMBER;
else if (cmd=="samples")
index=SAMPLES_JCTB;
else if (cmd=="storagecells")
index=STORAGE_CELL_NUMBER;
else if (cmd=="storagecell_start") {
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) {
int ival =-1;
if (!sscanf(args[1],"%d", &ival))
return string("cannot scan storage cell start value ")+string(args[1]);
myDet->setStoragecellStart(ival);
}
sprintf(answer,"%d", myDet->setStoragecellStart());
return string(answer);
}
else
return string("could not decode timer ")+cmd;
@ -5616,12 +5668,11 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
;//printf("value:%0.9lf\n",val);
else
return string("cannot scan timer value ")+string(args[1]);
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER) {
// t=(int64_t)(val*1E+9); for precision of eg.0.0000325, following done
val*=1E9;
t = (int64_t)val;
if(fabs(val-t)) // to validate precision loss
t = t + val - t; //even t += vak-t loses precision
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME ||
index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER ||
index == SUBFRAME_PERIOD) {
// +0.5 for precision of eg.0.0000325
t = ( val * 1E9 + 0.5);
}else t=(int64_t)val;
}
@ -5631,7 +5682,9 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
ret=myDet->setTimer(index,t);
if ((ret!=-1) && (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER)) {
if ((ret!=-1) && (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME
|| index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER ||
index == SUBFRAME_PERIOD)) {
rval=(double)ret*1E-9;
sprintf(answer,"%0.9f",rval);
}
@ -5658,6 +5711,9 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
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 << std::endl;
@ -5671,8 +5727,10 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
os << "probes \t gets the number of probes to accumulate" << std::endl;
os << "samples t \t gets the number of samples expected from the jctb" << std::endl;
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 << std::endl;
}
@ -5915,6 +5973,10 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
flag=DIGITAL_ONLY;
else if (sval=="analog_digital")
flag=ANALOG_AND_DIGITAL;
else if (sval=="overflow")
flag=SHOW_OVERFLOW;
else if (sval=="nooverflow")
flag=NOOVERFLOW;
else
return string("could not scan flag ")+string(args[1]);
}
@ -5943,6 +6005,10 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
strcat(answer,"digital " );
if (retval & ANALOG_AND_DIGITAL)
strcat(answer,"analog_digital ");
if (retval & SHOW_OVERFLOW)
strcat(answer,"overflow ");
if (retval & NOOVERFLOW)
strcat(answer,"nooverflow ");
if(strlen(answer))
return string(answer);
@ -6047,7 +6113,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "extsig:i mode \t sets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overlow, nooverflow, unknown." << std::endl;
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
@ -6060,9 +6126,8 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overflow, nooverflow, unknown" << std::endl;
os << "led \t returns led status (0 off, 1 on)" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
os << "powerchip \t gets if the chip has been powered on or off" << std::endl;
os << "auto_comp_disable \t Currently not implemented. gets if the automatic comparator diable mode is enabled/disabled" << std::endl;
@ -6279,6 +6344,43 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
}
else if(cmd=="r_framesperfile") {
if (action==PUT_ACTION){
if (sscanf(args[1],"%d",&ival)) {
myDet->setReceiverFramesPerFile(ival);
} else return string("could not scan max frames per file\n");
}
char answer[100];
memset(answer, 0, 100);
sprintf(answer,"%d", myDet->setReceiverFramesPerFile());
return string(answer);
}
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");
}
char answer[100];
memset(answer, 0, 100);
sprintf(answer,"%d",myDet->setReceiverFramesDiscardPolicy());
return string(answer);
}
else if(cmd=="r_padding") {
if (action==PUT_ACTION){
if (sscanf(args[1],"%d",&ival)) {
myDet->setReceiverPartialFramesPadding(ival);
} else return string("could not scan receiver padding enable\n");
}
char answer[100];
memset(answer, 0, 100);
sprintf(answer,"%d",myDet->setReceiverPartialFramesPadding());
return string(answer);
}
return string("could not decode command");
@ -6296,6 +6398,9 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
os << "tengiga \t sets system to be configure for 10Gbe if set to 1, else 1Gbe if set to 0" << std::endl;
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_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){
os << "receiver \t returns the status of receiver - can be running or idle" << std::endl;
@ -6305,6 +6410,9 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
os << "tengiga \t returns 1 if the system is configured for 10Gbe else 0 for 1Gbe" << std::endl;
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_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();
}

View File

@ -5,7 +5,7 @@
#include "sls_detector_defs.h"
#include "slsDetectorUtils.h"
using namespace std;
/** @short This class handles the command line I/Os, help etc. of the text clients */
@ -26,68 +26,66 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* \returns answer string */
/* *\/ */
virtual string executeLine(int narg, char *args[], int action);
virtual std::string executeLine(int narg, char *args[], int action);
/* /\** */
/* returns the help for the executeLine command */
/* \param os output stream to return the help to */
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* *\/ */
string helpLine(int narg, char *args[], int action=HELP_ACTION);
static string helpAcquire(int narg, char *args[], int action);
static string helpData(int narg, char *args[], int action);
static string helpFrame(int narg, char *args[], int action);
static string helpStatus(int narg, char *args[], int action);
static string helpDataStream(int narg, char *args[], int action);
static string helpFree(int narg, char *args[], int action);
static string helpAdd(int narg, char *args[], int action);
static string helpRemove(int narg, char *args[], int action);
static string helpHostname(int narg, char *args[], int action);
static string helpId(int narg, char *args[], int action);
static string helpMaster(int narg, char *args[], int action);
static string helpSync(int narg, char *args[], int action);
static string helpExitServer(int narg, char *args[], int action);
static string helpSettingsDir(int narg, char *args[], int action);
static string helpCalDir(int narg, char *args[], int action);
static string helpTrimEn(int narg, char *args[], int action);
static string helpOutDir(int narg, char *args[], int action);
static string helpFileName(int narg, char *args[], int action);
static string helpFileIndex(int narg, char *args[], int action);
static string helpFlatField(int narg, char *args[], int action);
static string helpRateCorr(int narg, char *args[], int action);
static string helpBadChannels(int narg, char *args[], int action);
static string helpAngConv(int narg, char *args[], int action);
static string helpThreaded(int narg, char *args[], int action);
static string helpPositions(int narg, char *args[], int action);
static string helpScripts(int narg, char *args[], int action);
static string helpScans(int narg, char *args[], int action);
static string helpNetworkParameter(int narg, char *args[], int action);
static string helpPort(int narg, char *args[], int action);
static string helpLock(int narg, char *args[], int action);
static string helpLastClient(int narg, char *args[], int action);
static string helpOnline(int narg, char *args[], int action);
static string helpConfigureMac(int narg, char *args[], int action);
static string helpDetectorSize(int narg, char *args[], int action);
static string helpSettings(int narg, char *args[], int action);
static string helpSN(int narg, char *args[], int action);
static string helpDigiTest(int narg, char *args[], int action);
static string helpRegister(int narg, char *args[], int action);
static string helpDAC(int narg, char *args[], int action);
static string helpTimer(int narg, char *args[], int action);
static string helpTiming(int narg, char *args[], int action);
static string helpTimeLeft(int narg, char *args[], int action);
static string helpSpeed(int narg, char *args[], int action);
static string helpAdvanced(int narg, char *args[], int action);
static string helpConfiguration(int narg, char *args[], int action);
static string helpImage(int narg, char *args[], int action);
static string helpCounter(int narg, char *args[], int action);
static string helpADC(int narg, char *args[], int action);
static string helpTempControl(int narg, char *args[], int action);
static string helpEnablefwrite(int narg, char *args[], int action);
static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action);
static string helpPattern(int narg, char *args[], int action);
static string helpPulse(int narg, char *args[], int action);
std::string helpLine(int narg, char *args[], int action=HELP_ACTION);
static std::string helpAcquire(int narg, char *args[], int action);
static std::string helpData(int narg, char *args[], int action);
static std::string helpFrame(int narg, char *args[], int action);
static std::string helpStatus(int narg, char *args[], int action);
static std::string helpDataStream(int narg, char *args[], int action);
static std::string helpFree(int narg, char *args[], int action);
static std::string helpHostname(int narg, char *args[], int action);
static std::string helpUser(int narg, char *args[], int action);
static std::string helpMaster(int narg, char *args[], int action);
static std::string helpSync(int narg, char *args[], int action);
static std::string helpExitServer(int narg, char *args[], int action);
static std::string helpSettingsDir(int narg, char *args[], int action);
static std::string helpCalDir(int narg, char *args[], int action);
static std::string helpTrimEn(int narg, char *args[], int action);
static std::string helpOutDir(int narg, char *args[], int action);
static std::string helpFileName(int narg, char *args[], int action);
static std::string helpFileIndex(int narg, char *args[], int action);
static std::string helpFlatField(int narg, char *args[], int action);
static std::string helpRateCorr(int narg, char *args[], int action);
static std::string helpBadChannels(int narg, char *args[], int action);
static std::string helpAngConv(int narg, char *args[], int action);
static std::string helpThreaded(int narg, char *args[], int action);
static std::string helpPositions(int narg, char *args[], int action);
static std::string helpScripts(int narg, char *args[], int action);
static std::string helpScans(int narg, char *args[], int action);
static std::string helpNetworkParameter(int narg, char *args[], int action);
static std::string helpPort(int narg, char *args[], int action);
static std::string helpLock(int narg, char *args[], int action);
static std::string helpLastClient(int narg, char *args[], int action);
static std::string helpOnline(int narg, char *args[], int action);
static std::string helpConfigureMac(int narg, char *args[], int action);
static std::string helpDetectorSize(int narg, char *args[], int action);
static std::string helpSettings(int narg, char *args[], int action);
static std::string helpSN(int narg, char *args[], int action);
static std::string helpDigiTest(int narg, char *args[], int action);
static std::string helpRegister(int narg, char *args[], int action);
static std::string helpDAC(int narg, char *args[], int action);
static std::string helpTimer(int narg, char *args[], int action);
static std::string helpTiming(int narg, char *args[], int action);
static std::string helpTimeLeft(int narg, char *args[], int action);
static std::string helpSpeed(int narg, char *args[], int action);
static std::string helpAdvanced(int narg, char *args[], int action);
static std::string helpConfiguration(int narg, char *args[], int action);
static std::string helpImage(int narg, char *args[], int action);
static std::string helpCounter(int narg, char *args[], int action);
static std::string helpADC(int narg, char *args[], int action);
static std::string helpTempControl(int narg, char *args[], int action);
static std::string helpEnablefwrite(int narg, char *args[], int action);
static std::string helpOverwrite(int narg, char *args[], int action);
static std::string helpReceiver(int narg, char *args[], int action);
static std::string helpPattern(int narg, char *args[], int action);
static std::string helpPulse(int narg, char *args[], int action);
@ -105,75 +103,72 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
slsDetectorUtils *myDet;
string cmdUnderDevelopment(int narg, char *args[], int action);
string cmdUnknown(int narg, char *args[], int action);
string cmdAcquire(int narg, char *args[], int action);
string cmdData(int narg, char *args[], int action);
string cmdFrame(int narg, char *args[], int action);
string cmdStatus(int narg, char *args[], int action);
string cmdDataStream(int narg, char *args[], int action);
string cmdFree(int narg, char *args[], int action);
string cmdAdd(int narg, char *args[], int action);
string cmdRemove(int narg, char *args[], int action);
string cmdHostname(int narg, char *args[], int action);
string cmdId(int narg, char *args[], int action);
string cmdMaster(int narg, char *args[], int action);
string cmdSync(int narg, char *args[], int action);
string cmdHelp(int narg, char *args[], int action);
string cmdExitServer(int narg, char *args[], int action);
string cmdSettingsDir(int narg, char *args[], int action);
string cmdCalDir(int narg, char *args[], int action);
string cmdTrimEn(int narg, char *args[], int action);
string cmdOutDir(int narg, char *args[], int action);
string cmdFileName(int narg, char *args[], int action);
string cmdFileIndex(int narg, char *args[], int action);
string cmdFlatField(int narg, char *args[], int action);
string cmdRateCorr(int narg, char *args[], int action);
string cmdBadChannels(int narg, char *args[], int action);
string cmdAngConv(int narg, char *args[], int action);
string cmdThreaded(int narg, char *args[], int action);
string cmdPositions(int narg, char *args[], int action);
string cmdScripts(int narg, char *args[], int action);
string cmdScans(int narg, char *args[], int action);
string cmdNetworkParameter(int narg, char *args[], int action);
string cmdPort(int narg, char *args[], int action);
string cmdLock(int narg, char *args[], int action);
string cmdLastClient(int narg, char *args[], int action);
string cmdOnline(int narg, char *args[], int action);
string cmdConfigureMac(int narg, char *args[], int action);
string cmdDetectorSize(int narg, char *args[], int action);
string cmdSettings(int narg, char *args[], int action);
string cmdSN(int narg, char *args[], int action);
string cmdDigiTest(int narg, char *args[], int action);
string cmdRegister(int narg, char *args[], int action);
string cmdDAC(int narg, char *args[], int action);
string cmdTiming(int narg, char *args[], int action);
string cmdTimer(int narg, char *args[], int action);
string cmdTimeLeft(int narg, char *args[], int action);
string cmdSpeed(int narg, char *args[], int action);
string cmdAdvanced(int narg, char *args[], int action);
string cmdConfiguration(int narg, char *args[], int action);
string cmdImage(int narg, char *args[], int action);
string cmdCounter(int narg, char *args[], int action);
string cmdADC(int narg, char *args[], int action);
string cmdTempControl(int narg, char *args[], int action);
string cmdEnablefwrite(int narg, char *args[], int action);
string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action);
string cmdPattern(int narg, char *args[], int action);
string cmdPulse(int narg, char *args[], int action);
std::string cmdUnderDevelopment(int narg, char *args[], int action);
std::string cmdUnknown(int narg, char *args[], int action);
std::string cmdAcquire(int narg, char *args[], int action);
std::string cmdData(int narg, char *args[], int action);
std::string cmdFrame(int narg, char *args[], int action);
std::string cmdStatus(int narg, char *args[], int action);
std::string cmdDataStream(int narg, char *args[], int action);
std::string cmdFree(int narg, char *args[], int action);
std::string cmdHostname(int narg, char *args[], int action);
std::string cmdUser(int narg, char *args[], int action);
std::string cmdMaster(int narg, char *args[], int action);
std::string cmdSync(int narg, char *args[], int action);
std::string cmdHelp(int narg, char *args[], int action);
std::string cmdExitServer(int narg, char *args[], int action);
std::string cmdSettingsDir(int narg, char *args[], int action);
std::string cmdCalDir(int narg, char *args[], int action);
std::string cmdTrimEn(int narg, char *args[], int action);
std::string cmdOutDir(int narg, char *args[], int action);
std::string cmdFileName(int narg, char *args[], int action);
std::string cmdFileIndex(int narg, char *args[], int action);
std::string cmdFlatField(int narg, char *args[], int action);
std::string cmdRateCorr(int narg, char *args[], int action);
std::string cmdBadChannels(int narg, char *args[], int action);
std::string cmdAngConv(int narg, char *args[], int action);
std::string cmdThreaded(int narg, char *args[], int action);
std::string cmdPositions(int narg, char *args[], int action);
std::string cmdScripts(int narg, char *args[], int action);
std::string cmdScans(int narg, char *args[], int action);
std::string cmdNetworkParameter(int narg, char *args[], int action);
std::string cmdPort(int narg, char *args[], int action);
std::string cmdLock(int narg, char *args[], int action);
std::string cmdLastClient(int narg, char *args[], int action);
std::string cmdOnline(int narg, char *args[], int action);
std::string cmdConfigureMac(int narg, char *args[], int action);
std::string cmdDetectorSize(int narg, char *args[], int action);
std::string cmdSettings(int narg, char *args[], int action);
std::string cmdSN(int narg, char *args[], int action);
std::string cmdDigiTest(int narg, char *args[], int action);
std::string cmdRegister(int narg, char *args[], int action);
std::string cmdDAC(int narg, char *args[], int action);
std::string cmdTiming(int narg, char *args[], int action);
std::string cmdTimer(int narg, char *args[], int action);
std::string cmdTimeLeft(int narg, char *args[], int action);
std::string cmdSpeed(int narg, char *args[], int action);
std::string cmdAdvanced(int narg, char *args[], int action);
std::string cmdConfiguration(int narg, char *args[], int action);
std::string cmdImage(int narg, char *args[], int action);
std::string cmdCounter(int narg, char *args[], int action);
std::string cmdADC(int narg, char *args[], int action);
std::string cmdTempControl(int narg, char *args[], int action);
std::string cmdEnablefwrite(int narg, char *args[], int action);
std::string cmdOverwrite(int narg, char *args[], int action);
std::string cmdReceiver(int narg, char *args[], int action);
std::string cmdPattern(int narg, char *args[], int action);
std::string cmdPulse(int narg, char *args[], int action);
int numberOfCommands;
string cmd;
std::string cmd;
typedef string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action);
typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action);
struct FuncTable
{
string m_pFuncName;
//const char* m_pFuncName;
std::string m_pFuncName;
MemFuncGetter m_pFuncPtr;
};

View File

@ -4,6 +4,8 @@
#include "multiSlsDetectorCommand.h"
using namespace std;
slsDetectorUsers::slsDetectorUsers(int id) : myDetector(NULL){
myDetector=new multiSlsDetector(id);
@ -151,43 +153,62 @@ int slsDetectorUsers::setThresholdEnergy(int e_eV){
return myDetector->setThresholdEnergy(e_eV);
}
double slsDetectorUsers::setExposureTime(double t, bool inseconds){
int64_t tms = (int64_t)(t * (1E+9));
if (t < 0) tms = -1;
if(!inseconds)
return myDetector->setExposureTime((int64_t)t);
else
return ((1E-9) * (double)myDetector->setExposureTime(tms));
int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int id) {
return myDetector->slsDetectorBase::setThresholdEnergy(e_ev, tb, isettings, id);
}
double slsDetectorUsers::setExposurePeriod(double t, bool inseconds){
int64_t tms = (int64_t)(t * (1E+9));
if (t < 0) tms = -1;
if(!inseconds)
return myDetector->setExposurePeriod((int64_t)t);
else
return ((1E-9) * (double)myDetector->setExposurePeriod(tms));
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);
}
}
double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds){
int64_t tms = (int64_t)(t * (1E+9));
if (t < 0) tms = -1;
if(!inseconds)
return myDetector->setDelayAfterTrigger((int64_t)t);
else
return ((1E-9) * (double)myDetector->setDelayAfterTrigger(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);
}
}
int64_t slsDetectorUsers::setNumberOfGates(int64_t t){
return myDetector->setNumberOfGates(t);
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);
}
}
int64_t slsDetectorUsers::setNumberOfGates(int64_t t, int imod){
return myDetector->setNumberOfGates(t,imod);
}
int64_t slsDetectorUsers::setNumberOfFrames(int64_t t){
return myDetector->setNumberOfFrames(t);
int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int imod){
return myDetector->setNumberOfFrames(t,imod);
}
int64_t slsDetectorUsers::setNumberOfCycles(int64_t t){
return myDetector->setNumberOfCycles(t);
int64_t slsDetectorUsers::setNumberOfCycles(int64_t t, int imod){
return myDetector->setNumberOfCycles(t,imod);
}
int slsDetectorUsers::setTimingMode(int pol){
@ -343,6 +364,12 @@ int slsDetectorUsers::setParallelMode(int value) {
return myDetector->getParallelMode();
}
int slsDetectorUsers::setOverflowMode(int value) {
if(value >= 0)
myDetector->setOverflowMode(value);
return myDetector->getOverflowMode();
}
int slsDetectorUsers::setAllTrimbits(int val, int id) {
return myDetector->setAllTrimbits(val, id);
}
@ -399,3 +426,26 @@ int slsDetectorUsers::setFlowControl10G(int i) {
int slsDetectorUsers::setTenGigabitEthernet(int i) {
return myDetector->enableTenGigabitEthernet(i);
}
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::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));
}

View File

@ -22,7 +22,7 @@ class multiSlsDetectorCommand;
#include <string>
using namespace std;
@ -100,7 +100,7 @@ class slsDetectorUsers
@short useful to define subset of working functions
\returns "PSI" or "Dectris"
*/
string getDetectorDeveloper();
std::string getDetectorDeveloper();
@ -138,20 +138,20 @@ class slsDetectorUsers
/**
@short returns the default output files path
*/
string getFilePath();
std::string getFilePath();
/**
@short sets the default output files path
\param s file path
\returns file path
*/
string setFilePath(string s);
std::string setFilePath(std::string s);
/**
@short
\returns the default output files root name
*/
string getFileName();
std::string getFileName();
/**
@short sets the default output files path
@ -159,7 +159,7 @@ class slsDetectorUsers
\returns the default output files root name
*/
string setFileName(string s);
std::string setFileName(std::string s);
/**
@short
@ -178,27 +178,27 @@ class slsDetectorUsers
@short get flat field corrections file directory
\returns flat field correction file directory
*/
string getFlatFieldCorrectionDir();
std::string getFlatFieldCorrectionDir();
/**
@short set flat field corrections file directory
\param dir flat field correction file directory
\returns flat field correction file directory
*/
string setFlatFieldCorrectionDir(string dir);
std::string setFlatFieldCorrectionDir(std::string dir);
/**
@short get flat field corrections file name
\returns flat field correction file name
*/
string getFlatFieldCorrectionFile();
std::string getFlatFieldCorrectionFile();
/**
@short set flat field correction file
\param fname name of the flat field file (or "" if disable)
\returns 0 if disable (or file could not be read), >0 otherwise
*/
int setFlatFieldCorrectionFile(string fname="");
int setFlatFieldCorrectionFile(std::string fname="");
@ -310,52 +310,68 @@ class slsDetectorUsers
*/
int setThresholdEnergy(int e_eV);
/**
@short set threshold energy with choice to load trimbits (eiger only)
\param e_ev threshold in ev
\param tb 1 loads trimbits, 0 does not load trimbits
\param isettings settings index (-1 uses current setting)
\param id module index (-1 for all)
\returns current threshold value in ev (-1 failed)
*/
int setThresholdEnergy(int e_ev, int tb, int isettings = -1, int id = -1);
/**
@short set/get exposure time value
\param t time in sn (-1 gets)
\param inseconds true if the value is in s, else ns
\param imod module number (-1 for all)
\returns timer set value in ns, or s if specified
*/
double setExposureTime(double t=-1, bool inseconds=false);
double setExposureTime(double t=-1, bool inseconds=false, int imod = -1);
/**
@short set/get exposure period
\param t time in ns (-1 gets)
\param inseconds true if the value is in s, else ns
\param imod module number (-1 for all)
\returns timer set value in ns, or s if specified
*/
double setExposurePeriod(double t=-1, bool inseconds=false);
double setExposurePeriod(double t=-1, bool inseconds=false, int imod = -1);
/**
@short set/get delay after trigger
\param t time in ns (-1 gets)
\param inseconds true if the value is in s, else ns
\param imod module number (-1 for all)
\returns timer set value in ns, or s if specified
*/
double setDelayAfterTrigger(double t=-1, bool inseconds=false);
double setDelayAfterTrigger(double t=-1, bool inseconds=false, int imod = -1);
/**
@short set/get number of gates
\param t number of gates (-1 gets)
\param imod module number (-1 for all)
\returns number of gates
*/
int64_t setNumberOfGates(int64_t t=-1);
int64_t setNumberOfGates(int64_t t=-1, int imod = -1);
/**
@short set/get number of frames i.e. number of exposure per trigger
\param t number of frames (-1 gets)
\param imod module number (-1 for all)
\returns number of frames
*/
int64_t setNumberOfFrames(int64_t t=-1);
int64_t setNumberOfFrames(int64_t t=-1, int imod = -1);
/**
@short set/get number of cycles i.e. number of triggers
\param t number of frames (-1 gets)
\param imod module number (-1 for all)
\returns number of frames
*/
int64_t setNumberOfCycles(int64_t t=-1);
int64_t setNumberOfCycles(int64_t t=-1, int imod = -1);
/**
@ -370,7 +386,7 @@ class slsDetectorUsers
\param fname file name
\returns OK or FAIL
*/
int readConfigurationFile(string const fname);
int readConfigurationFile(std::string const fname);
/**
@ -379,20 +395,20 @@ class slsDetectorUsers
\returns OK or FAIL
*/
int dumpDetectorSetup(string const fname);
int dumpDetectorSetup(std::string const fname);
/**
@short Loads the detector setup from file
\param fname file to read from
\returns OK or FAIL
*/
int retrieveDetectorSetup(string const fname);
int retrieveDetectorSetup(std::string const fname);
/**
@short useful for data plotting etc.
\returns Mythen, Eiger, Gotthard etc.
*/
string getDetectorType();
std::string getDetectorType();
/**
@short sets the mode by which gui requests data from receiver
@ -433,7 +449,7 @@ class slsDetectorUsers
\param var optional parameter - unused.
*/
virtual void addFrame(double *data, double pos, double i0, double t, string fname, double var);
virtual void addFrame(double *data, double pos, double i0, double t, std::string fname, double var);
/**
@short finalizes the data set returning the array of angles, values and errors to be used as final data - can be overcome by the user's functions thanks to the virtual property
@ -478,18 +494,18 @@ class slsDetectorUsers
/** (for expert users)
* Set/Get receiver streaming out ZMQ IP
* By default, it is the IP of receiver hostname
* @param ip sets, empty string gets
* @param ip sets, empty std::string gets
* @returns receiver streaming out ZMQ IP
*/
string setReceiverDataStreamingOutIP(string ip="");
std::string setReceiverDataStreamingOutIP(std::string ip="");
/** (for expert users)
* Set/Get client streaming in ZMQ IP
* By default, it is the IP of receiver hostname
* @param i sets, empty string gets
* @param i sets, empty std::string gets
* @returns client streaming in ZMQ IP
*/
string setClientDataStreamingInIP(string ip="");
std::string setClientDataStreamingInIP(std::string ip="");
/**
get get Module Firmware Version
@ -580,18 +596,18 @@ class slsDetectorUsers
\param narg value to be set
\param args value to be set
\param pos position of detector in multislsdetector list
\returns answer string
\returns answer std::string
*/
string putCommand(int narg, char *args[], int pos=-1);
std::string putCommand(int narg, char *args[], int pos=-1);
/**
@short gets parameters in command interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf
\param narg value to be set
\param args value to be set
\param pos position of detector in multislsdetector list
\returns answer string
\returns answer std::string
*/
string getCommand(int narg, char *args[], int pos=-1);
std::string getCommand(int narg, char *args[], int pos=-1);
/************************************************************************
@ -612,6 +628,13 @@ class slsDetectorUsers
*/
int setParallelMode(int value);
/**
* @short show saturated for overflow in subframes in 32 bit mode (eiger only)
* \param value 0 for do not show saturatd, 1 for show saturated (-1 gets)
* \returns overflow mode enable in 32 bit mode
*/
int setOverflowMode(int value);
/**
@short sets all trimbits to value (only available for eiger)
\param val value to be set (-1 gets)
@ -622,20 +645,20 @@ class slsDetectorUsers
/**
@short set dac value
\param dac dac as string. can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp. others not supported
\param dac dac as std::string. can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp. others not supported
\param val value to be set (-1 gets)
\param id module index (-1 for all)
\returns dac value or -1 (if id=-1 & dac value is different for all modules) or -9999 if dac string does not match
\returns dac value or -1 (if id=-1 & dac value is different for all modules) or -9999 if dac std::string does not match
*/
int setDAC(string dac, int val, int id = -1);
int setDAC(std::string dac, int val, int id = -1);
/**
@short get adc value
\param adc adc as string. can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr. others not supported
\param adc adc as std::string. can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr. others not supported
\param id module index (-1 for all)
\returns adc value in millidegree Celsius or -1 (if id=-1 & adc value is different for all modules) or -9999 if adc string does not match
\returns adc value in millidegree Celsius or -1 (if id=-1 & adc value is different for all modules) or -9999 if adc std::string does not match
*/
int getADC(string adc, int id = -1);
int getADC(std::string adc, int id = -1);
/**
@short start receiver listening mode
@ -705,35 +728,57 @@ class slsDetectorUsers
*/
int setTenGigabitEthernet(int i = -1);
/**
* returns total number of detector modules
* @returns the total number of detector modules
*/
int getNMods();
/**
* Set sub frame exposure time (only for Eiger)
* @param i sub frame exposure time (-1 gets)
* @param inseconds true if the value is in s, else ns
* @returns sub frame exposure time in ns, or s if specified
*/
double setSubFrameExposureTime(double t=-1, bool inseconds=false);
/**
* Set sub frame period (only for Eiger)
* @param i sub frame period (-1 gets)
* @param inseconds true if the value is in s, else ns
* @returns sub frame period in ns, or s if specified
*/
double setSubFrameExposurePeriod(double t=-1, bool inseconds=false);
/************************************************************************
STATIC FUNCTIONS
*********************************************************************/
/** @short returns string from run status index
/** @short returns std::string from run status index
\param s run status index
\returns string error, waiting, running, data, finished or unknown when wrong index
\returns std::string error, waiting, running, data, finished or unknown when wrong index
*/
static string runStatusType(int s){ \
static std::string runStatusType(int s){ \
switch (s) { \
case 0: return string("idle"); \
case 1: return string("error"); \
case 2: return string("waiting"); \
case 3: return string("finished"); \
case 4: return string("data"); \
case 5: return string("running"); \
default: return string("unknown"); \
case 0: return std::string("idle"); \
case 1: return std::string("error"); \
case 2: return std::string("waiting"); \
case 3: return std::string("finished"); \
case 4: return std::string("data"); \
case 5: return std::string("running"); \
default: return std::string("unknown"); \
}};
/** @short returns detector settings string from index
/** @short returns detector settings std::string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain
\returns setting index (-1 unknown string)
\returns setting index (-1 unknown std::string)
*/
static int getDetectorSettings(string s){ \
static int getDetectorSettings(std::string s){ \
if (s=="standard") return 0; \
if (s=="fast") return 1; \
if (s=="highgain") return 2; \
@ -743,47 +788,48 @@ class slsDetectorUsers
if (s=="veryhighgain") return 6; \
return -1; };
/** @short returns detector settings string from index
/** @short returns detector settings std::string from index
\param s settings index
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined when wrong index
*/
static string getDetectorSettings(int s){\
static std::string getDetectorSettings(int s){\
switch(s) { \
case 0: return string("standard");\
case 1: return string("fast");\
case 2: return string("highgain");\
case 3: return string("dynamicgain"); \
case 4: return string("lowgain"); \
case 5: return string("mediumgain"); \
case 6: return string("veryhighgain"); \
default: return string("undefined"); \
case 0: return std::string("standard");\
case 1: return std::string("fast");\
case 2: return std::string("highgain");\
case 3: return std::string("dynamicgain"); \
case 4: return std::string("lowgain"); \
case 5: return std::string("mediumgain"); \
case 6: return std::string("veryhighgain"); \
default: return std::string("undefined"); \
}};
/**
@short returns external communication mode string from index
@short returns external communication mode std::string from index
\param f index for communication mode
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode
*/
static string getTimingMode(int f){ \
static std::string getTimingMode(int f){ \
switch(f) { \
case 0: return string( "auto"); \
case 1: return string("trigger"); \
case 2: return string("ro_trigger"); \
case 3: return string("gating"); \
case 4: return string("triggered_gating"); \
default: return string( "unknown"); \
case 0: return std::string( "auto"); \
case 1: return std::string("trigger"); \
case 2: return std::string("ro_trigger"); \
case 3: return std::string("gating"); \
case 4: return std::string("triggered_gating"); \
case 5: return std::string("burst_trigger"); \
default: return std::string( "unknown"); \
} };
/**
@short returns external communication mode string from index
@short returns external communication mode std::string from index
\param s index for communication mode
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode
*/
static int getTimingMode(string s){ \
static int getTimingMode(std::string s){ \
if (s== "auto") return 0; \
if (s== "trigger") return 1; \
if (s== "ro_trigger") return 2; \

View File

@ -9,7 +9,9 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include <time.h> //clock()
#include <string>
using namespace std;
slsDetectorUtils::slsDetectorUtils() {

View File

@ -31,7 +31,7 @@ extern "C" {
#include <math.h>
#include <semaphore.h>
#include <cstdlib>
using namespace std;
//#include "slsDetectorActions_Standalone.h"
@ -110,7 +110,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
int setReceiverDataStreamingOutPort(int i) { \
if (i >= 0) { \
ostringstream ss; ss << i; string s = ss.str(); \
std::ostringstream ss; ss << i; std::string s = ss.str(); \
int prev_streaming = enableDataStreamingFromReceiver(); \
setNetworkParameter(RECEIVER_STREAMING_PORT, s); \
if (prev_streaming) { \
@ -126,7 +126,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
int setClientDataStreamingInPort(int i){ \
if (i >= 0) { \
ostringstream ss; ss << i; string s = ss.str(); \
std::ostringstream ss; ss << i; std::string s = ss.str(); \
int prev_streaming = enableDataStreamingToClient(); \
setNetworkParameter(CLIENT_STREAMING_PORT, s); \
if (prev_streaming) { \
@ -140,7 +140,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
* @param i sets, -1 gets
* @returns receiver streaming out ZMQ port
*/
string setReceiverDataStreamingOutIP(string ip) { \
std::string setReceiverDataStreamingOutIP(std::string ip) { \
if (ip.length()) { \
int prev_streaming = enableDataStreamingFromReceiver(); \
setNetworkParameter(RECEIVER_STREAMING_SRC_IP, ip); \
@ -155,7 +155,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
* @param i sets, -1 gets
* @returns client streaming in ZMQ port
*/
string setClientDataStreamingInIP(string ip){ \
std::string setClientDataStreamingInIP(std::string ip){ \
if (ip.length()) { \
int prev_streaming = enableDataStreamingToClient(); \
setNetworkParameter(CLIENT_STREAMING_SRC_IP, ip); \
@ -199,47 +199,24 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param pos position in the multi detector structure (is -1 returns concatenated hostnames divided by a +)
\returns hostname
*/
virtual string getHostname(int pos=-1)=0;
virtual std::string getHostname(int pos=-1)=0;
/** sets the detector hostname
\param name hostname
\param pos position in the multi detector structure (is -1 expects concatenated hostnames divided by a +)
\returns hostname
*/
virtual string setHostname(const char* name, int pos=-1)=0;
virtual void setHostname(const char* name)=0;
/** adds the detector hostnames to the end of the list
\param name hostname
*/
virtual void addMultipleDetectors(const char* name)=0;
/** returns the detector type
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
\returns type
*/
virtual string sgetDetectorsType(int pos=-1)=0;
/** returns the detector type
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
\returns type
*/
virtual detectorType setDetectorsType(detectorType t=GET_DETECTOR_TYPE, int pos=-1)=0;
virtual string ssetDetectorsType(detectorType t=GET_DETECTOR_TYPE, int pos=-1)=0;
virtual string ssetDetectorsType(string s, int pos=-1)=0;
/** Gets the detector id (shared memory id) of an slsDetector
\param i position in the multiSlsDetector structure
\return id or -1 if FAIL
*/
virtual int getDetectorId(int i=-1)=0;
/** Sets the detector id (shared memory id) of an slsDetector in a multiSlsDetector structure
\param ival id to be set
\param i position in the multiSlsDetector structure
\return id or -1 if FAIL (e.g. in case of an slsDetector)
*/
virtual int setDetectorId(int ival, int i=-1){return -1;};
virtual std::string sgetDetectorsType(int pos=-1)=0;
/**
gets the network parameters (implemented for gotthard)
@ -247,7 +224,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\returns parameter
*/
virtual string getNetworkParameter(networkParameter i)=0;
virtual std::string getNetworkParameter(networkParameter i)=0;
/**
sets the network parameters
@ -257,14 +234,14 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\returns parameter
*/
virtual string setNetworkParameter(networkParameter i, string s)=0;
virtual std::string setNetworkParameter(networkParameter i, std::string s)=0;
int setFlowControl10G(int i = -1) {
string sret="";
std::string sret="";
if (i != -1) {
ostringstream o;
std::ostringstream o;
o << ((i >= 1) ? 1 : 0);
string sval = o.str();
std::string sval = o.str();
sret = setNetworkParameter(FLOW_CONTROL_10G, sval);
} else
sret = getNetworkParameter(FLOW_CONTROL_10G);
@ -284,7 +261,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
checks if the detector(s) are online/offline
\returns hostname if offline
*/
virtual string checkOnline()=0;
virtual std::string checkOnline()=0;
/**
Digital test of the modules
@ -308,7 +285,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
returns currently the loaded trimfile/settingsfile name
*/
virtual string getSettingsFile()=0;
virtual std::string getSettingsFile()=0;
/**
@ -318,6 +295,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
virtual int64_t getTimeLeft(timerIndex index)=0;
/**
* set storage cell that stores first acquisition of the series (Jungfrau only)
* \param value storage cell index. Value can be 0 to 15. (-1 gets)
* \returns the storage cell that stores the first acquisition of the series
*/
virtual int setStoragecellStart(int pos=-1)=0;
/** sets the number of trim energies and their value \sa sharedSlsDetector
@ -375,7 +359,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
int setBadChannelCorrection(string fname, int &nbadtot, int *badchanlist, int off=0);
int setBadChannelCorrection(std::string fname, int &nbadtot, int *badchanlist, int off=0);
@ -398,32 +382,29 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
returns the detector trimbit/settings directory
*/
virtual char* getSettingsDir()=0;
virtual std::string getSettingsDir()=0;
/** sets the detector trimbit/settings directory */
virtual char* setSettingsDir(string s)=0;
virtual std::string setSettingsDir(std::string s)=0;
/**
returns the location of the calibration files
*/
virtual char* getCalDir()=0;
virtual std::string getCalDir()=0;
/**
sets the location of the calibration files
*/
virtual char* setCalDir(string s)=0;
virtual std::string setCalDir(std::string s)=0;
/** Frees the shared memory - should not be used except for debugging*/
virtual int freeSharedMemory()=0;
/** adds the detector with ID id in postion pos
\param id of the detector to be added (should already exist!)
\param pos position where it should be added (normally at the end of the list (default to -1)
\returns the actual number of detectors or -1 if it failed (always for slsDetector)
*/
virtual int addSlsDetector(int id, int pos=-1){return -1;};
virtual void freeSharedMemory()=0;
/**
* Get user details of shared memory
* @returns string with user details
*/
virtual std::string getUserDetails() = 0;
/** adds the detector name in position pos
\param name of the detector to be added (should already exist in shared memory or at least be online)
@ -433,19 +414,6 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual int addSlsDetector(char* name, int pos=-1){return -1;};
/**
removes the detector in position pos from the multidetector
\param pos position of the detector to be removed from the multidetector system (defaults to -1 i.e. last detector)
\returns the actual number of detectors or -1 if it failed (always for slsDetector)
*/
virtual int removeSlsDetector(int pos=-1){return -1;};
/**removes the detector in position pos from the multidetector
\param name is the name of the detector
\returns the actual number of detectors or -1 if it failed (always for slsDetector)
*/
virtual int removeSlsDetector(char* name){return -1;};
/**
Turns off the server - do not use except for debugging!
*/
@ -460,7 +428,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\fname file name to load data from
\returns OK or FAIL
*/
virtual int loadImageToDetector(imageType index,string const fname)=0;
virtual int loadImageToDetector(imageType index,std::string const fname)=0;
/**
@ -469,7 +437,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\fname file fname to load data from
\returns OK or FAIL
*/
virtual int writeCounterBlockFile(string const fname,int startACQ=0)=0;
virtual int writeCounterBlockFile(std::string const fname,int startACQ=0)=0;
/**
@ -599,7 +567,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
Returns the IP of the last client connecting to the detector
*/
virtual string getLastClientIP()=0;
virtual std::string getLastClientIP()=0;
@ -616,13 +584,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param imod module number, -1 means all modules
\returns OK or FAIL
*/
virtual int loadSettingsFile(string fname, int imod=-1)=0;
virtual int loadSettingsFile(std::string fname, int imod=-1)=0;
/** programs FPGA with pof file
\param fname file name
\returns OK or FAIL
*/
virtual int programFPGA(string fname)=0;
virtual int programFPGA(std::string fname)=0;
/** resets FPGA
\returns OK or FAIL
@ -646,7 +614,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param imod module number, -1 means all modules
\returns OK or FAIL
*/
virtual int saveSettingsFile(string fname, int imod=-1)=0;
virtual int saveSettingsFile(std::string fname, int imod=-1)=0;
/** sets all the trimbits to a particular value
\param val trimbit value
@ -716,7 +684,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param fname file name
\returns OK or FAIL
*/
virtual int writeConfigurationFile(string const fname)=0;
virtual int writeConfigurationFile(std::string const fname)=0;
void registerGetPositionCallback( double (*func)(void*),void *arg){get_position=func; POarg=arg;};
@ -740,7 +708,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\returns OK or FAIL
*/
int dumpDetectorSetup(string const fname, int level=0);
int dumpDetectorSetup(std::string const fname, int level=0);
/**
@ -750,7 +718,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\returns OK or FAIL
*/
int retrieveDetectorSetup(string const fname, int level=0);
int retrieveDetectorSetup(std::string const fname, int level=0);
static int dummyAcquisitionFinished(double prog,int status,void* p){cout <<"Acquisition finished callback! " << prog << " " << status << endl; return 0;}
static int dummyMeasurementFinished(int im,int findex,void* p){cout <<"Measurement finished callback! " << im << " " << findex << endl; return 0;}
@ -764,12 +732,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
Checks if the receiver is really online
*/
virtual string checkReceiverOnline()=0;
virtual std::string checkReceiverOnline()=0;
/**
Returns the IP of the last client connecting to the receiver
*/
virtual string getReceiverLastClientIP()=0;
virtual std::string getReceiverLastClientIP()=0;
/**
@ -777,14 +745,35 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
@param fileName fileDir file directory
\returns file dir
*/
virtual string setFilePath(string s="")=0;
virtual std::string setFilePath(std::string s="")=0;
/**
Sets up the file name
@param fileName file name
\returns file name
*/
virtual string setFileName(string s="")=0;
virtual std::string setFileName(std::string s="")=0;
/**
Sets the max frames per file in receiver
@param f max frames per file
\returns max frames per file in receiver
*/
virtual int setReceiverFramesPerFile(int f = -1) = 0;
/**
Sets the frames discard policy in receiver
@param f frames discard policy
\returns frames discard policy set in receiver
*/
virtual frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY) = 0;
/**
Sets the partial frames padding enable in receiver
@param f partial frames padding enable
\returns partial frames padding enable in receiver
*/
virtual int setReceiverPartialFramesPadding(int f = -1) = 0;
/**
Sets up the file format
@ -796,12 +785,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
\returns file dir
*/
virtual string getFilePath()=0;
virtual std::string getFilePath()=0;
/**
\returns file name
*/
virtual string getFileName()=0;
virtual std::string getFileName()=0;
/**
\returns file name
@ -935,7 +924,7 @@ virtual int setReceiverSilentMode(int i = -1)=0;
@param fname pattern file to open
@returns OK/FAIL
*/
virtual int setCTBPattern(string fname)=0;
virtual int setCTBPattern(std::string fname)=0;
/** Writes a pattern word to the CTB
@ -1014,6 +1003,14 @@ virtual int setReceiverSilentMode(int i = -1)=0;
virtual bool isAcquireReady() = 0;
/**
* Check version compatibility with detector/receiver software
* (if hostname/rx_hostname has been set/ sockets created)
* \param p port type control port or data (receiver) port
* \returns FAIL for incompatibility, OK for compatibility
*/
virtual int checkVersionCompatibility(portType t) = 0;
protected:

View File

@ -12,7 +12,7 @@
#include <queue>
#include <math.h>
using namespace std;
;
/**
@short class handling the data file I/O flags
*/

View File

@ -13,7 +13,7 @@
#include "sls_detector_defs.h"
#endif
using namespace std;
;
class angCalLogClass {
@ -27,7 +27,7 @@ class angCalLogClass {
char *argv[2]; \
argv[0]=cmd; \
sprintf(cmd,"_%d.angcal",det->getFileIndex()); \
outfile.open(string(det->getFilePath()+string("/")+det->getFileName()+string(cmd)).c_str()); \
outfile.open( std::string(det->getFilePath()+ std::string("/")+det->getFileName()+ std::string(cmd)).c_str()); \
outfile.precision(8);
myDet=new slsDetectorCommand(det); \
if (outfile.is_open()) { \
@ -44,12 +44,12 @@ class angCalLogClass {
#endif
int addStep(double pos, string fname) {std::cout.precision(5); outfile << pos << " " << fname << endl; return 0;};
int addStep(double pos, std::string fname) {std::cout.precision(5); outfile << pos << " " << fname << endl; return 0;};
//
int readHeader(ifstream &infile, int &maxmod, int &nmod, int &chanspermod, char *angconvfile, double &globaloff, double &fineoff, int &angdir, char *ffdir, char *fffile, char *badfile ) { \
int readHeader(std::ifstream &infile, int &maxmod, int &nmod, int &chanspermod, char *angconvfile, double &globaloff, double &fineoff, int &angdir, char *ffdir, char *fffile, char *badfile ) { \
nmod=0; chanspermod=0; globaloff=0; fineoff=0; angdir=1; \
strcpy(angconvfile,"none"); strcpy(ffdir,"none"); strcpy(fffile,"none"); strcpy(badfile,"none"); \
char line[1000], myvar[100], myarg[100]; \
@ -57,14 +57,14 @@ class angCalLogClass {
for (int iv=0; iv<nvars; iv++) { \
infile.getline(line,1000); \
sscanf(line,"%s %s", myvar, myarg); \
if (string(myvar)!=string(vars[iv]))
if ( std::string(myvar)!= std::string(vars[iv]))
cout << "Found variable " << myvar << " instead of " << vars[iv] << endl;
else
switch (iv) { \
case 0: \
if (string(myarg).find("Mythen")!=string::npos) \
if ( std::string(myarg).find("Mythen")!= std::string::npos) \
chanspermod=1280; \
else if (string(myarg).find("Gotthard")!=string::npos) \
else if ( std::string(myarg).find("Gotthard")!= std::string::npos) \
chanspermod=1280; \
else \
chanspermod=65535; \
@ -106,7 +106,7 @@ class angCalLogClass {
return 0; \
};
int getStep(ifstream &infile, double &threshold, char *datafname){ \
int getStep(std::ifstream &infile, double &threshold, char *datafname){ \
char line[1000]; \
float v;
infile.getline(line,1000); \
@ -140,7 +140,7 @@ class angCalLogClass {
#ifndef MYROOT
slsDetectorCommand *myDet;
#endif
ofstream outfile;
std::ofstream outfile;
char vars[100][100];
int nvars;

View File

@ -19,7 +19,7 @@
//double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction)
using namespace std;
//
/**
@short Angular conversion constants needed for a detector module
@ -58,7 +58,7 @@ class angularConversion : public virtual slsDetectorBase, public angularConversi
pure virtual function
\param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector
*/
virtual int writeAngularConversion(string fname)=0;
virtual int writeAngularConversion(std::string fname)=0;
/**
sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize();
\param mp already merged postions
@ -250,19 +250,19 @@ class angularConversion : public virtual slsDetectorBase, public angularConversi
\returns angular conversion flag
*/
int setAngularConversionFile(string fname);
int setAngularConversionFile(std::string fname);
/**
returns the angular conversion file
*/
string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");};
std::string getAngularConversionFile(){if (setAngularCorrectionMask()) return std::string(angConvFile); else return std::string("none");};
/**
reads teh angular conversion file for the (multi)detector and writes it to shared memory
*/
virtual int readAngularConversionFile(string fname="")=0;
virtual int readAngularConversionFile(std::string fname="")=0;

View File

@ -19,7 +19,7 @@
class angleConversionConstant;
using namespace std;
;
/**
@short Angular conversion constants needed for a detector module
@ -47,7 +47,7 @@ class angularConversionStatic
//virtual int readAngularConversion(string fname)=0;
//virtual int readAngularConversion(std::string fname)=0;
@ -60,7 +60,7 @@ class angularConversionStatic
\param angOff pointer to array of angleConversionConstants
\returns OK or FAIL
*/
static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
static int readAngularConversion(std::string fname, int nmod, angleConversionConstant *angOff);
/**
reads an angular conversion file
@ -70,7 +70,7 @@ class angularConversionStatic
\returns OK or FAIL
*/
static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff);
static int readAngularConversion(std::ifstream& ifs, int nmod, angleConversionConstant *angOff);
/**
writes an angular conversion file
\param fname file to be written
@ -78,7 +78,7 @@ class angularConversionStatic
\param angOff pointer to array of angleConversionConstants
\returns OK or FAIL
*/
static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
static int writeAngularConversion(std::string fname, int nmod, angleConversionConstant *angOff);
/**
writes an angular conversion file
@ -87,7 +87,7 @@ class angularConversionStatic
\param angOff pointer to array of angleConversionConstants
\returns OK or FAIL
*/
static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff);
static int writeAngularConversion(std::ofstream& ofs, int nmod, angleConversionConstant *angOff);
/**
sets the arrays of the merged data to 0. NB The array should be created with size nbins >= 360./getBinSize();

View File

@ -7,30 +7,30 @@
#include <sstream>
#include <string.h>
using namespace std;
//
class badChannelCorrections{
public:
static int readBadChannelCorrectionFile(string fname, int &nbad, int *badlist){ ifstream infile(fname.c_str()); int nb=-1; if (infile.is_open()) {nb=readBadChannelCorrectionFile(infile,nbad,badlist); infile.close();}; return nb;};
static int readBadChannelCorrectionFile(std::string fname, int &nbad, int *badlist){ std::ifstream infile(fname.c_str()); int nb=-1; if (infile.is_open()) {nb=readBadChannelCorrectionFile(infile,nbad,badlist); infile.close();}; return nb;};
static int readBadChannelCorrectionFile(ifstream &infile, int &nbad, int *badlist, int moff=0){ \
static int readBadChannelCorrectionFile(std::ifstream &infile, int &nbad, int *badlist, int moff=0){ \
int interrupt=0; \
int ich; \
int chmin,chmax; \
string str; \
std::string str; \
nbad=0; \
while (infile.good() and interrupt==0) { \
getline(infile,str); \
istringstream ssstr; \
std::istringstream ssstr; \
ssstr.str(str); \
if (ssstr.bad() || ssstr.fail() || infile.eof()) { \
interrupt=1; \
break; \
} \
if (str.find('-')!=string::npos) { \
if (str.find('-')!=std::string::npos) { \
ssstr >> chmin ; \
ssstr.str(str.substr(str.find('-')+1,str.size())); \
ssstr >> chmax; \
@ -47,7 +47,7 @@ class badChannelCorrections{
return nbad; };
static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ \
static int setBadChannelCorrection(std::ifstream &infile, int &nbad, int *badlist, int moff){ \
int retval=readBadChannelCorrectionFile(infile,nbad,badlist); \
for (int ich=0; ich<nbad; ich++) { badlist[ich]=badlist[ich]+moff; }; \
return retval; \

View File

@ -15,7 +15,7 @@
#include "sls_detector_defs.h"
#endif
using namespace std;
;
class enCalLogClass {
@ -32,7 +32,7 @@ class enCalLogClass {
strcpy(vars[3],"modulenumber"); \
argv[0]=cmd; \
sprintf(cmd,"_%d.encal",det->getFileIndex()); \
outfile.open(string(det->getFilePath()+string("/")+det->getFileName()+string(cmd)).c_str()); \
outfile.open(std::string(det->getFilePath()+std::string("/")+det->getFileName()+std::string(cmd)).c_str()); \
myDet=new slsDetectorCommand(det); \
strcpy(cmd,vars[0]); \
outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \
@ -58,12 +58,12 @@ class enCalLogClass {
#endif
int addStep(double threshold, string fname) {outfile << threshold << " " << fname << endl; return 0;};
int addStep(double threshold, std::string fname) {outfile << threshold << " " << fname << endl; return 0;};
//
int readHeader(ifstream &infile, char *settings, int &nmod, int &chanspermod, int *mods ) { \
int readHeader(std::ifstream &infile, char *settings, int &nmod, int &chanspermod, int *mods ) { \
nmod=0; strcpy(settings,"unknown"); chanspermod=0; \
char line[1000],myarg[100]; \
int dum; \
@ -75,9 +75,9 @@ class enCalLogClass {
break; \
case 1: \
sscanf(line,"type %s", myarg); \
if (string(myarg).find("Mythen")!=string::npos) \
if (std::string(myarg).find("Mythen")!=std::string::npos) \
chanspermod=1280; \
else if (string(myarg).find("Gotthard")!=string::npos) \
else if (std::string(myarg).find("Gotthard")!=std::string::npos) \
chanspermod=1280; \
else \
chanspermod=65535; \
@ -101,7 +101,7 @@ class enCalLogClass {
return 0; \
};
int getStep(ifstream &infile, double &threshold, char *datafname){ \
int getStep(std::ifstream &infile, double &threshold, char *datafname){ \
char line[1000]; \
float v;
infile.getline(line,1000); \
@ -122,7 +122,7 @@ class enCalLogClass {
#ifndef MYROOT
slsDetectorCommand *myDet;
#endif
ofstream outfile;
std::ofstream outfile;
char vars[4][100];
};

View File

@ -16,7 +16,7 @@ class TGraphErrors;
#endif
using namespace std;

View File

@ -149,8 +149,8 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS};
//Copy other dacs
int num_dacs_to_copy = 9;
int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,CAL,RXB_RB,RXB_LB,VCN,VIS};
int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS};
int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]);
for (int i = 0; i < num_dacs_to_copy; ++i) {
if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) {
deleteModule(myMod);
@ -159,9 +159,19 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]];
}
//Copy irrelevant dacs (without failing): CAL
if (a->dacs[CAL] != b->dacs[CAL]) {
printf("Warning: DAC CAL differs in both energies (%d, %d)! ",
a->dacs[CAL], b->dacs[CAL]);
printf("Taking first: %d\n", a->dacs[CAL]);
}
myMod->dacs[CAL] = a->dacs[CAL];
//Interpolate vrf, vcmp, vcp
int num_dacs_to_interpolate = 7;
int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS};
int num_dacs_to_interpolate = sizeof(dacs_to_interpolate) / sizeof(dacs_to_interpolate[0]);
for (int i = 0; i < num_dacs_to_interpolate; ++i) {
myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2,
a->dacs[dacs_to_interpolate[i]], b->dacs[dacs_to_interpolate[i]]);

View File

@ -13,7 +13,7 @@
#include <cmath>
#include <string>
using namespace std;
/**
@short class handling the energy calibration and trim files IO
*/
@ -39,7 +39,7 @@ class energyConversion
\returns OK if successful, else FAIL or -1
*/
static int readCalibrationFile(string fname, double &gain, double &offset);
static int readCalibrationFile(std::string fname, double &gain, double &offset);
/**
writes a calibration file
@ -48,7 +48,7 @@ class energyConversion
\param offset
\returns OK if successful, else FAIL or -1
*/
static int writeCalibrationFile(string fname, double gain, double offset);
static int writeCalibrationFile(std::string fname, double gain, double offset);
/**
reads a calibration file
@ -57,7 +57,7 @@ class energyConversion
\param offset reference to the offset variable
\returns OK if successful, else FAIL or -1
*/
static int readCalibrationFile(string fname, int *gain, int *offset);
static int readCalibrationFile(std::string fname, int *gain, int *offset);
/**
writes a calibration file
@ -66,7 +66,7 @@ class energyConversion
\param offset reference to the offset variable
\returns OK if successful, else FAIL or -1
*/
static int writeCalibrationFile(string fname, int *gain, int *offset);
static int writeCalibrationFile(std::string fname, int *gain, int *offset);
@ -108,7 +108,7 @@ class energyConversion
\returns the pointer to myMod or NULL if reading the file failed
*/
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1);
sls_detector_module* readSettingsFile(std::string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1);
/**
writes a trim/settings file
@ -121,7 +121,7 @@ class energyConversion
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
*/
int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau);
int writeSettingsFile(std::string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau);
/** allocates the momery for a detector module structure
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)

View File

@ -1,6 +1,6 @@
#include "fileIO.h"
using namespace std;
/* I/O */

View File

@ -14,7 +14,7 @@
#include <math.h>
#include <semaphore.h>
using namespace std;
//
/**
@short class handling the data file I/O flags
*/
@ -50,14 +50,14 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
using fileIOStatic::writeDataFile;
using fileIOStatic::createFileName;
int getFileIndexFromFileName(string fname){
int getFileIndexFromFileName(std::string fname){
int ret;
pthread_mutex_lock(&mf);
ret=fileIOStatic::getFileIndexFromFileName(fname);
pthread_mutex_unlock(&mf);
return ret;
};
int getIndicesFromFileName(string fname, int &index){
int getIndicesFromFileName(std::string fname, int &index){
int ret;
pthread_mutex_lock(&mf);
ret=fileIOStatic::getIndicesFromFileName(fname,index);
@ -67,7 +67,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
int getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1){
int getVariablesFromFileName(std::string fname, int &index, int &p_index, double &sv0, double &sv1){
int ret;
pthread_mutex_lock(&mf);
@ -76,7 +76,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
return ret;
};
int getVariablesFromFileName(string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex){
int getVariablesFromFileName(std::string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex){
int ret;
@ -91,11 +91,11 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param s file path
\return actual file path
*/
virtual string setFilePath(string s) {
virtual std::string setFilePath(std::string s) {
pthread_mutex_lock(&mf);
sprintf(filePath, s.c_str());
pthread_mutex_unlock(&mf);
return string(filePath);
return std::string(filePath);
};
/**
@ -103,11 +103,11 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param s file name to be set
\returns actual file name
*/
virtual string setFileName(string s) {
virtual std::string setFileName(std::string s) {
pthread_mutex_lock(&mf);
sprintf(fileName, s.c_str());
pthread_mutex_unlock(&mf);
return string(fileName);};
return std::string(fileName);};
/**
sets the default output file index
@ -160,14 +160,22 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param i detector index to be set
\returns actual detector index
*/
virtual int setDetectorIndex(int i) {detIndex=i;return detIndex;};
virtual int setDetectorIndex(int i) {
pthread_mutex_lock(&mf);
detIndex=i;
pthread_mutex_unlock(&mf);
return detIndex;};
/**
sets the default file format
\param i file format to be set
\returns actual file frame format
*/
virtual fileFormat setFileFormat(int i) {*fileFormatType=(fileFormat)i; return *fileFormatType;};
virtual fileFormat setFileFormat(int i) {
pthread_mutex_lock(&mf);
*fileFormatType=(fileFormat)i;
pthread_mutex_unlock(&mf);
return *fileFormatType; };
@ -175,11 +183,11 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\returns the output files path
*/
virtual string getFilePath() {return string(filePath);};
virtual std::string getFilePath() {return std::string(filePath);};
/**
\returns the output files root name
*/
virtual string getFileName() {return string(fileName);};
virtual std::string getFileName() {return std::string(fileName);};
/**
\returns the output file index
@ -212,9 +220,9 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
virtual fileFormat getFileFormat() {return *fileFormatType;};
string createFileName();
std::string createFileName();
string createReceiverFilePrefix();
std::string createReceiverFilePrefix();
/**
@ -227,7 +235,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
\returns OK or FAIL if it could not write the file or data=NULL
*/
virtual int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1);
virtual int writeDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1);
/**
@ -244,7 +252,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\returns OK or FAIL if it could not write the file or data=NULL
*/
virtual int writeDataFile(ofstream &outfile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1, int offset=0);
virtual int writeDataFile(std::ofstream &outfile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1, int offset=0);
/**
@ -253,7 +261,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param data array of data values
\returns OK or FAIL if it could not write the file or data=NULL
*/
virtual int writeDataFile(string fname, int *data);
virtual int writeDataFile(std::string fname, int *data);
virtual int writeDataFile(void *data, int iframe=-1);
@ -266,7 +274,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param offset start channel number
\returns OK or FAIL if it could not write the file or data=NULL
*/
virtual int writeDataFile(ofstream &outfile, int *data, int offset=0);
virtual int writeDataFile(std::ofstream &outfile, int *data, int offset=0);
@ -276,7 +284,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param data array of data values
\returns OK or FAIL if it could not write the file or data=NULL
*/
virtual int writeDataFile(string fname, short int *data);
virtual int writeDataFile(std::string fname, short int *data);
@ -291,7 +299,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param offset start channel number
\returns OK or FAIL if it could not write the file or data=NULL
*/
virtual int writeDataFile(ofstream &outfile, short int *data, int offset=0);
virtual int writeDataFile(std::ofstream &outfile, short int *data, int offset=0);
/**
@ -304,7 +312,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param dataformat format of the data: can be 'i' integer or 'f' double (default)
\returns OK or FAIL if it could not read the file or data=NULL
*/
virtual int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f');
virtual int readDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f');
/**
reads a data file
@ -316,7 +324,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param offset start channel number to be expected
\returns OK or FAIL if it could not read the file or data=NULL
*/
int readDataFile(ifstream& infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0);
int readDataFile(std::ifstream& infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0);
/**
reads a raw data file
@ -324,7 +332,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param data array of data values
\returns OK or FAIL if it could not read the file or data=NULL
yes */
virtual int readDataFile(string fname, int *data);
virtual int readDataFile(std::string fname, int *data);
/**
reads a raw data file
@ -333,7 +341,7 @@ yes */
\param offset first channel number to be expected
\returns OK or FAIL if it could not read the file or data=NULL
*/
int readDataFile(ifstream &infile, int *data, int offset=0);
int readDataFile(std::ifstream &infile, int *data, int offset=0);
/**
@ -342,7 +350,7 @@ yes */
\param data array of data values
\returns OK or FAIL if it could not read the file or data=NULL
*/
virtual int readDataFile(string fname, short int *data);
virtual int readDataFile(std::string fname, short int *data);
/**
reads a short int raw data file
\param infile input file stream
@ -350,12 +358,12 @@ yes */
\param offset first channel number to be expected
\returns OK or FAIL if it could not read the file or data=NULL
*/
int readDataFile(ifstream &infile, short int *data, int offset=0);
int readDataFile(std::ifstream &infile, short int *data, int offset=0);
virtual int getDataBytes ( )=0;
friend class slsDetector;
string getCurrentFileName(){return currentFileName;};
std::string getCurrentFileName(){return currentFileName;};
protected:
@ -368,12 +376,12 @@ yes */
void incrementDetectorIndex() { (detIndex)++; };
string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;};
std::string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;};
string currentFileName;
std::string currentFileName;
string currentReceiverFilePrefix;
std::string currentReceiverFilePrefix;
/** output directory */
@ -397,7 +405,7 @@ yes */
FILE *filefd;
ofstream fstream;
std::ofstream fstream;
int nframes;
// int fformat;

View File

@ -14,8 +14,11 @@
#define MYROOT
#endif
using std::endl;
using std::cout;
#include "sls_detector_defs.h"
using namespace std;
//
/**
@short class handling the data file I/O flags
*/
@ -56,11 +59,11 @@ class fileIOStatic {
\param detindex detector id
\returns file name without extension
*/
static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \
ostringstream osfn; \
static std::string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \
std::ostringstream osfn; \
osfn << filepath << "/" << filename; \
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << std::fixed << std::setprecision(prec0) << sv0; \
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << std::fixed << std::setprecision(prec1) << sv1; \
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
if(detindex>=0) osfn << "_d"<< detindex; \
if(frameindex>=0) osfn << "_f" << frameindex; \
@ -86,11 +89,11 @@ class fileIOStatic {
\param detindex detector id
\returns file name without extension
*/
static string createReceiverFilePrefix(char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos,int detindex=-1){ \
ostringstream osfn; \
static std::string createReceiverFilePrefix(char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos,int detindex=-1){ \
std::ostringstream osfn; \
osfn << filename; \
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << std::fixed << std::setprecision(prec0) << sv0; \
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << std::fixed << std::setprecision(prec1) << sv1; \
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
if(detindex!=-1) osfn << "_d"<< detindex; \
return osfn.str(); \
@ -101,13 +104,13 @@ class fileIOStatic {
\param fname file name
\returns file index
*/
static int getFileIndexFromFileName(string fname){ \
static int getFileIndexFromFileName(std::string fname){ \
int i; \
size_t dot=fname.rfind("."); \
if (dot==string::npos) \
if (dot==std::string::npos) \
return -1; \
size_t uscore=fname.rfind("_"); \
if (uscore==string::npos) return -1; \
if (uscore==std::string::npos) return -1; \
if (sscanf( fname.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) return i; \
cout << "******************************** cannot parse file index" << endl; \
return 0; \
@ -118,11 +121,11 @@ class fileIOStatic {
\param index reference to index
\returns frame index
*/
static int getIndicesFromFileName(string fname,int &index){ \
static int getIndicesFromFileName(std::string fname,int &index){ \
int i; \
string s; \
std::string s; \
size_t uscore=fname.rfind("_"); \
if (uscore==string::npos) return -1; \
if (uscore==std::string::npos) return -1; \
s=fname; \
if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)){ \
index=i; \
@ -146,16 +149,16 @@ class fileIOStatic {
\param sv1 reference to scan variable 1
\returns file index
*/
static int getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1) { \
static int getVariablesFromFileName(std::string fname, int &index, int &p_index, double &sv0, double &sv1) { \
int i; \
double f; \
string s; \
std::string s; \
index=-1; \
p_index=-1; \
sv0=-1; \
sv1=-1; \
size_t uscore=fname.rfind("_"); \
if (uscore==string::npos) return -1; \
if (uscore==std::string::npos) return -1; \
s=fname; \
if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \
index=i; \
@ -201,16 +204,16 @@ class fileIOStatic {
\param detindex reference to detector id
\returns file index
*/
static int getVariablesFromFileName(string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex) { \
static int getVariablesFromFileName(std::string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex) { \
int i; \
double f; \
string s; \
std::string s; \
index=-1; \
p_index=-1; \
sv0=-1; \
sv1=-1; \
size_t uscore=fname.rfind("_"); \
if (uscore==string::npos) return -1; \
if (uscore==std::string::npos) return -1; \
s=fname; \
if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \
index=i; \
@ -262,7 +265,7 @@ class fileIOStatic {
\param detindex reference to detector id
\returns file name
*/
static int verifySameFrame(string fname, int index, int f_index, int p_index, double sv0, double sv1, int detindex) { \
static int verifySameFrame(std::string fname, int index, int f_index, int p_index, double sv0, double sv1, int detindex) { \
int new_index=-1;
int new_f_index=-1;
int new_p_index=-1;
@ -283,10 +286,10 @@ class fileIOStatic {
\param fname complete file name prefix
\returns file name
*/
static string getNameFromReceiverFilePrefix(string fname) { \
static std::string getNameFromReceiverFilePrefix(std::string fname) { \
int i; \
double f; \
string s; \
std::string s; \
s=fname; \
size_t uscore=s.rfind("_"); \
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \
@ -313,14 +316,14 @@ class fileIOStatic {
\param fname complete file name
\returns file name without file name prefix, detector index or extension
*/
static string getReceiverFileNameToConcatenate(string fname) { \
static std::string getReceiverFileNameToConcatenate(std::string fname) { \
int i;double f; \
string s=fname; \
std::string s=fname; \
if(fname.empty()) return fname; \
size_t dot=s.find(".");
size_t uscore=s.rfind("_"); \
if (uscore==string::npos) return "??"; \
if (uscore==std::string::npos) return "??"; \
if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) \
s=fname.substr(0,uscore); \
uscore=s.rfind("_"); \
@ -358,13 +361,13 @@ class fileIOStatic {
*/
static int writeDataFile(string fname, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'){ \
ofstream outfile; \
static int writeDataFile(std::string fname, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'){ \
std::ofstream outfile; \
if (data==NULL) { \
cout << "No data to write!" << endl; \
return slsDetectorDefs::FAIL; \
} \
outfile.open (fname.c_str(),ios_base::out); \
outfile.open (fname.c_str(),std::ios_base::out); \
if (outfile.is_open()) { \
writeDataFile(outfile, nch, data, err, ang, dataformat, 0); \
outfile.close(); \
@ -389,7 +392,7 @@ class fileIOStatic {
\param offset start channel number
\returns OK or FAIL if it could not write the file or data=NULL
*/
static int writeDataFile(ofstream &outfile, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0){
static int writeDataFile(std::ofstream &outfile, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0){
int idata; \
if (data==NULL || nch==0) { \
cout << "No data to write!" << endl; \
@ -426,10 +429,10 @@ class fileIOStatic {
\param data array of data values
\returns OK or FAIL if it could not write the file or data=NULL
*/
static int writeDataFile(string fname,int nch, int *data){ \
ofstream outfile; \
static int writeDataFile(std::string fname,int nch, int *data){ \
std::ofstream outfile; \
if (data==NULL) return slsDetectorDefs::FAIL; \
outfile.open (fname.c_str(),ios_base::out); \
outfile.open (fname.c_str(),std::ios_base::out); \
if (outfile.is_open()) { \
writeDataFile(outfile, nch, data, 0); \
outfile.close(); \
@ -447,7 +450,7 @@ class fileIOStatic {
\param data array of data values
\returns OK or FAIL if it could not write the file or data=NULL
*/
static int writeBinaryDataFile(string fname, size_t nbytes, void *data){ \
static int writeBinaryDataFile(std::string fname, size_t nbytes, void *data){ \
FILE *sfilefd; \
if (data==NULL) return slsDetectorDefs::FAIL; \
sfilefd = fopen(fname.c_str(), "w"); \
@ -473,7 +476,7 @@ class fileIOStatic {
\param offset start channel number
\returns OK or FAIL if it could not write the file or data=NULL
*/
static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0){ \
static int writeDataFile(std::ofstream &outfile,int nch, int *data, int offset=0){ \
if (data==NULL) return slsDetectorDefs::FAIL; \
for (int ichan=0; ichan<nch; ichan++) outfile << ichan+offset << " " << *(data+ichan) << std::endl; \
return slsDetectorDefs::OK; \
@ -490,10 +493,10 @@ class fileIOStatic {
\param data array of data values
\returns OK or FAIL if it could not write the file or data=NULL
*/
static int writeDataFile(string fname,int nch, short int *data) { \
ofstream outfile; \
static int writeDataFile(std::string fname,int nch, short int *data) { \
std::ofstream outfile; \
if (data==NULL) return slsDetectorDefs::FAIL; \
outfile.open (fname.c_str(),ios_base::out); \
outfile.open (fname.c_str(),std::ios_base::out); \
if (outfile.is_open()) { \
writeDataFile(outfile, nch, data, 0); \
outfile.close(); \
@ -514,7 +517,7 @@ class fileIOStatic {
\param offset start channel number
\returns OK or FAIL if it could not write the file or data=NULL
*/
static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0){ \
static int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset=0){ \
if (data==NULL) return slsDetectorDefs::FAIL; \
for (int ichan=0; ichan<nch; ichan++) outfile << ichan+offset << " " << *(data+ichan) << std::endl; \
return slsDetectorDefs::OK; \
@ -531,11 +534,11 @@ class fileIOStatic {
\returns number of channels read or -1 if it could not read the file or data=NULL
*/
static int readDataFile(int nch, string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f') { \
ifstream infile; \
static int readDataFile(int nch, std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f') { \
std::ifstream infile; \
int iline=0; \
string str; \
infile.open(fname.c_str(), ios_base::in); \
std::string str; \
infile.open(fname.c_str(), std::ios_base::in); \
if (infile.is_open()) { \
iline=readDataFile(nch, infile, data, err, ang, dataformat, 0); \
infile.close(); \
@ -558,17 +561,17 @@ class fileIOStatic {
\returns number of channels read or -1 if it could not read the file or data=NULL
*/
static int readDataFile(int nch, ifstream &infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0){ \
static int readDataFile(int nch, std::ifstream &infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0){ \
int ichan,iline=0; \
int interrupt=0; \
double fdata, ferr, fang; \
int maxchans; \
int ich; \
string str; \
std::string str; \
maxchans=nch; \
while (infile.good() and interrupt==0) { \
getline(infile,str); \
istringstream ssstr(str); \
std::istringstream ssstr(str); \
if (ang==NULL) { \
ssstr >> ichan >> fdata; \
if (ssstr.fail() || ssstr.bad()) { \
@ -617,11 +620,11 @@ class fileIOStatic {
\param nch number of channels
\returns OK or FAIL if it could not read the file or data=NULL
*/
static int readDataFile(string fname, int *data, int nch) { \
ifstream infile; \
static int readDataFile(std::string fname, int *data, int nch) { \
std::ifstream infile; \
int iline=0; \
string str; \
infile.open(fname.c_str(), ios_base::in); \
std::string str; \
infile.open(fname.c_str(), std::ios_base::in); \
if (infile.is_open()) { \
iline=readDataFile(infile, data, nch, 0); \
infile.close(); \
@ -641,13 +644,13 @@ class fileIOStatic {
\param offset start channel value
\returns OK or FAIL if it could not read the file or data=NULL
*/
static int readDataFile(ifstream &infile, int *data, int nch, int offset) { \
static int readDataFile(std::ifstream &infile, int *data, int nch, int offset) { \
int ichan, idata, iline=0; \
int interrupt=0; \
string str; \
std::string str; \
while (infile.good() and interrupt==0) { \
getline(infile,str); \
istringstream ssstr(str); \
std::istringstream ssstr(str); \
ssstr >> ichan >> idata; \
if (ssstr.fail() || ssstr.bad()) { \
interrupt=1; \
@ -673,11 +676,11 @@ class fileIOStatic {
\param nch number of channels
\returns OK or FAIL if it could not read the file or data=NULL
*/
static int readDataFile(string fname, short int *data, int nch){ \
ifstream infile; \
static int readDataFile(std::string fname, short int *data, int nch){ \
std::ifstream infile; \
int iline=0; \
string str; \
infile.open(fname.c_str(), ios_base::in); \
std::string str; \
infile.open(fname.c_str(), std::ios_base::in); \
if (infile.is_open()) { \
iline=readDataFile(infile, data, nch, 0); \
infile.close(); \
@ -696,14 +699,14 @@ class fileIOStatic {
\param offset start channel value
\returns OK or FAIL if it could not read the file or data=NULL
*/
static int readDataFile(ifstream &infile, short int *data, int nch, int offset) { \
static int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) { \
int ichan, iline=0; \
short int idata; \
int interrupt=0; \
string str; \
std::string str; \
while (infile.good() and interrupt==0) { \
getline(infile,str); \
istringstream ssstr(str); \
std::istringstream ssstr(str); \
ssstr >> ichan >> idata; \
if (ssstr.fail() || ssstr.bad()) { \
interrupt=1; \

View File

@ -16,7 +16,7 @@
#include <queue>
#include <math.h>
using namespace std;
;
typedef double double32_t;

View File

@ -8,7 +8,7 @@
#endif
#include <time.h>
using namespace std;
//#define VERBOSE
static void* startProcessData(void *n){

View File

@ -7,7 +7,6 @@
#include "angularConversion.h"
#include "badChannelCorrections.h"
#include "fileIO.h"
#include <string>
#include <iostream>
#include <fstream>
@ -22,8 +21,7 @@
class postProcessingFuncs;
using namespace std;
//
#define MAX_BADCHANS 20000
@ -77,7 +75,7 @@ class postProcessing : public angularConversion, public fileIO, public badChanne
\param fname file with bad channel list ("" disable)
\returns 0 if bad channel disabled, >0 otherwise
*/
virtual int setBadChannelCorrection(string fname="")=0;
virtual int setBadChannelCorrection(std::string fname="")=0;
/**
@ -87,7 +85,7 @@ class postProcessing : public angularConversion, public fileIO, public badChanne
\param badlist array of badchannels
\returns 0 if bad channel disabled, >0 otherwise
*/
virtual int setBadChannelCorrection(string fname, int &nbad, int *badlist, int off=0)=0;
virtual int setBadChannelCorrection(std::string fname, int &nbad, int *badlist, int off=0)=0;
using badChannelCorrections::setBadChannelCorrection;
/**
@ -118,26 +116,26 @@ class postProcessing : public angularConversion, public fileIO, public badChanne
/** returns the bad channel list file */
string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return string(badChanFile); else return string("none");};
std::string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return std::string(badChanFile); else return std::string("none");};
/**
get flat field corrections file directory
\returns flat field correction file directory
*/
string getFlatFieldCorrectionDir(){return string(flatFieldDir);};
std::string getFlatFieldCorrectionDir(){return std::string(flatFieldDir);};
/**
set flat field corrections file directory
\param flat field correction file directory
\returns flat field correction file directory
*/
string setFlatFieldCorrectionDir(string dir){strcpy(flatFieldDir,dir.c_str()); return string(flatFieldDir);};
std::string setFlatFieldCorrectionDir(std::string dir){strcpy(flatFieldDir,dir.c_str()); return std::string(flatFieldDir);};
/**
get flat field corrections file name
\returns flat field correction file name
*/
string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<<FLAT_FIELD_CORRECTION)) return string(flatFieldFile); else return string("none");};
std::string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<<FLAT_FIELD_CORRECTION)) return std::string(flatFieldFile); else return std::string("none");};
@ -172,7 +170,7 @@ s
\returns nothing
*/
void doProcessing(double* myData, int delflag, string fname);
void doProcessing(double* myData, int delflag, std::string fname);
/**
@ -260,7 +258,7 @@ s
void initDataset(int refresh);
void addFrame(double *data, double pos, double i0, double t, string fname, double var);
void addFrame(double *data, double pos, double i0, double t, std::string fname, double var);
void finalizeDataset(double *a, double *v, double *e, int &np);
virtual detectorType getDetectorsType(int pos=-1)=0;
@ -295,11 +293,11 @@ s
/**
data queue
*/
queue<int*> dataQueue;
std::queue<int*> dataQueue;
/**
queue containing the postprocessed data
*/
queue<detectorData*> finalDataQueue;
std::queue<detectorData*> finalDataQueue;
/** data queue size */
int queuesize;

View File

@ -25,7 +25,7 @@
class angularConversion;
class fileIO;
using namespace std;
;
#define MAX_BADCHANS 2000

View File

@ -1,6 +1,6 @@
#include "postProcessingFuncs.h"
#include "angleConversionConstant.h"
using namespace std;
//#define VERBOSE
postProcessingFuncs::postProcessingFuncs(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY):
@ -303,16 +303,17 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
totalChans=0;
chansPerMod=new int [nMods];
if (nMods)
chansPerMod=new int [nMods];
moduleMask=new int [nMods];
if (nMods)
moduleMask=new int [nMods];
nBins=0;
if (angRadius && angOffset && angCenter && (binSize>0)) {
// cout << "??????? creating angConv"<< endl;
angConv=new angleConversionConstant*[nMods];
if (nMods)
angConv=new angleConversionConstant*[nMods];
nBins=(int)(360./binSize)+1;
}
//#ifdef VERBOSE
@ -380,11 +381,15 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
void postProcessingFuncs::deletePointers() {
delete [] chansPerMod;
chansPerMod=NULL;
if(chansPerMod != NULL) {
delete [] chansPerMod;
chansPerMod=NULL;
}
delete [] moduleMask;
moduleMask=NULL;
if (moduleMask != NULL) {
delete [] moduleMask;
moduleMask=NULL;
}
if (badChannelMask) {

View File

@ -17,7 +17,7 @@
#include "angularConversionStatic.h"
class angleConversionConstant;
using namespace std;
class postProcessingFuncs : public virtual angularConversionStatic

View File

@ -18,7 +18,7 @@
class angularConversion;
using namespace std;
;
#define MAX_BADCHANS 2000

View File

@ -34,7 +34,7 @@
#include "runningStat.h"
#include "movingStat.h"
#include "single_photon_hit.h"
using namespace std;
typedef double double32_t;

View File

@ -105,7 +105,7 @@ htmldoc:
clean:
# cd manual && make clean
rm -rf $(BIN)/sls_detector_put $(BIN)/sls_detector_get $(BIN)/sls_detector_acquire $(BIN)/sls_detector_help
rm -rf $(BIN)/sls_detector_put $(BIN)/sls_detector_get $(BIN)/sls_detector_acquire $(BIN)/sls_detector_help $(BIN)/gui_client
install: clients

View File

@ -73,7 +73,7 @@ int64_t get64BitReg(int aLSB, int aMSB){
vMSB=bus_r(aMSB);
v64=vMSB;
v64=(v64<<32) | vLSB;
printf(" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, v64);
printf(" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64);
return v64;
}
@ -148,7 +148,9 @@ int mapCSP0(void) {
return FAIL;
}
#endif
printf("CSPOBASE mapped from 0x%llx to 0x%llx\n",CSP0BASE, CSP0BASE+MEM_SIZE);
printf("CSPOBASE mapped from 0x%llx to 0x%llx\n",
(long long unsigned int)CSP0BASE,
(long long unsigned int)(CSP0BASE+MEM_SIZE));
printf("Status Register: %08x\n",bus_r(STATUS_REG));
}else

View File

@ -11,7 +11,8 @@
/* global variables */
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
int gpioDefined=0;
char mtdvalue[10];
#define MTDSIZE 10
char mtdvalue[MTDSIZE];
@ -67,9 +68,10 @@ void eraseFlash(){
printf("\nErasing Flash\n");
#endif
char command[255];
memset(command, 0, 255);
sprintf(command,"flash_eraseall %s",mtdvalue);
system(command);
printf("flash erased\n");
printf("Flash erased\n");
}
/**
@ -85,14 +87,24 @@ int startWritingFPGAprogram(FILE** filefp){
//getting the drive
char output[255];
memset(output, 0, 255);
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
fgets(output, sizeof(output), fp);
if (fp == NULL) {
cprintf(RED,"popen returned NULL. Need that to get mtd drive.\n");
return 1;
}
if (fgets(output, sizeof(output), fp) == NULL) {
cprintf(RED,"fgets returned NULL. Need that to get mtd drive.\n");
return 1;
}
pclose(fp);
//cprintf(RED,"output: %s\n", output);
memset(mtdvalue, 0, MTDSIZE);
strcpy(mtdvalue,"/dev/");
char* pch = strtok(output,":");
if(pch == NULL){
cprintf(RED,"Could not get mtd value\n");
return FAIL;
return 1;
}
strcat(mtdvalue,pch);
printf ("\nFlash drive found: %s\n",mtdvalue);
@ -105,7 +117,7 @@ int startWritingFPGAprogram(FILE** filefp){
cprintf(RED,"Unable to open %s in write mode\n",mtdvalue);
return 1;
}
printf("flash ready for writing\n");
printf("Flash ready for writing\n");
return 0;
}
@ -161,12 +173,12 @@ int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){
#ifdef VERY_VERBOSE
printf("\nWriting of FPGA Program\n");
cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc);
cprintf(BLUE,"fsize:%d\n",fsize);
cprintf(BLUE,"fsize:%lu\n",fsize);
cprintf(BLUE,"pointer:%p\n",(void*)filefp);
#endif
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
cprintf(RED,"Could not write FPGA source to flash\n");
cprintf(RED,"Could not write FPGA source to flash (size:%lu)\n", fsize);
return 1;
}
#ifdef VERY_VERBOSE

View File

@ -17,6 +17,11 @@ Here are the definitions, but the actual implementation should be done for each
// basic tests
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARD)
int isFirmwareCheckDone();
int getFirmwareCheckResult(char** mess);
#endif
void checkFirmwareCompatibility(int flag);
#if defined(MYTHEN3D) || defined(JUNGFRAUD)
int checkType();
@ -58,6 +63,9 @@ void getModuleConfiguration();
// set up detector
void allocateDetectorStructureMemory();
void setupDetector();
#ifdef JUNGFRAUD
int setDefaultDacs();
#endif
// advanced read/write reg
@ -85,6 +93,7 @@ int configureFrequency(int val, int i);
int autoCompDisable(int on);
int adcPhase(int st);
int getPhase();
void configureASICTimer();
#endif
// parameters - nmod, dr, roi
@ -105,6 +114,9 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
#endif
// parameters - timer
#ifdef JUNGFRAUD
int selectStoragecellStart(int pos);
#endif
int64_t setTimer(enum timerIndex ind, int64_t val);
#ifndef EIGERD
int64_t getTimeLeft(enum timerIndex ind);

View File

@ -20,55 +20,73 @@ void error(char *msg){
}
int main(int argc, char *argv[]){
int portno, b;
int retval=OK;
int portno = DEFAULT_PORTNO;
int retval = OK;
int sd, fd;
int debugflag = 0;
int controlserver = 1;
// if socket crash, ignores SISPIPE, prevents global signal handler
// subsequent read/write to socket gives error - must handle locally
signal(SIGPIPE, SIG_IGN);
// circumvent the basic tests
if(argc > 1) {
if(!strcasecmp(argv[1],"-debug")){
debugflag = 1;
argc=1;
}
}
{
int i;
for (i = 1; i < argc; ++i) {
if(!strcasecmp(argv[i],"-stopserver")) {
cprintf(BLUE,"Detected stop server\n");
controlserver = 0;
}
else if(!strcasecmp(argv[i],"-devel")){
cprintf(BLUE,"Detected developer mode\n");
debugflag = 1;
}
#ifdef JUNGFRAUD
else if(!strcasecmp(argv[i],"-update")){
cprintf(BLUE,"Detected update mode\n");
debugflag = PROGRAMMING_MODE;
}
#endif
else if(strchr(argv[i],'-') != NULL) {
cprintf(RED,"cannot scan program argument %s\n", argv[1]);
return -1;
}
}
}
#ifdef STOP_SERVER
char cmd[100];
memset(cmd, 0, 100);
#endif
if (argc==1) {
if (controlserver) {
portno = DEFAULT_PORTNO;
cprintf(BLUE,
"********************************************************\n"
"********* opening control server on port %d **********\n"
"********************************************************\n\n"
, portno);
b=1;
basictests(debugflag);
#ifdef STOP_SERVER
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
//cprintf(BLUE,"cmd:%s\n", cmd);
system(cmd);
{
int i;
for (i = 0; i < argc; ++i)
sprintf(cmd, "%s %s", cmd, argv[i]);
sprintf(cmd,"%s -stopserver&", cmd);
cprintf(BLUE,"cmd:%s\n", cmd);
system(cmd);
}
#endif
} else {
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) == 0) {
printf("could not open stop server: unknown port\n");
return 1;
}
cprintf(BLUE,
"********************************************************\n"
"*********** opening stop server on port %d ***********\n"
"********************************************************\n\n"
, portno);
b=0;
}
init_detector(b); //defined in slsDetectorServer_funcs
setModeFlag(debugflag); //defined in slsDetectorServer_funcs
init_detector(controlserver); //defined in slsDetectorServer_funcs
sd=bindSocket(portno); //defined in communication_funcs
sockfd=sd;
@ -83,7 +101,7 @@ int main(int argc, char *argv[]){
printf("function table assigned \n");
#endif
if (b)
if (controlserver)
printf("\nControl Server Ready...\n\n");
else
printf("\nStop Server Ready...\n\n");

View File

@ -52,8 +52,11 @@ int printSocketReadError() {
return FAIL;
}
void basictests(int flag) {
void setModeFlag(int flag) {
debugflag = flag;
}
void basictests() {
#ifdef SLS_DETECTOR_FUNCTION_LIST
checkFirmwareCompatibility(debugflag);
#endif
@ -68,6 +71,10 @@ void init_detector(int controlserver) {
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (controlserver) {
isControlServer = 1;
basictests();
#ifdef JUNGFRAUD
if (debugflag != PROGRAMMING_MODE)
#endif
initControlServer();
#ifdef EIGERD
dhcpipad = getDetectorIP();
@ -102,6 +109,14 @@ int decode_function(int file_des) {
#ifdef VERBOSE
printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]);
#endif
#ifdef JUNGFRAUD
if ((debugflag == PROGRAMMING_MODE) &&
((fnum != F_PROGRAM_FPGA) && (fnum != F_GET_DETECTOR_TYPE) &&
(fnum != F_RESET_FPGA) && (fnum != F_UPDATE_CLIENT))) {
sprintf(mess,"This Function %s cannot be executed. ", getFunctionName((enum detFuncs)fnum));
ret=(M_nofuncMode)(file_des);
} else
#endif
if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) {
cprintf(BG_RED,"Unknown function enum %d\n", fnum);
@ -193,6 +208,8 @@ const char* getFunctionName(enum detFuncs func) {
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
case F_TEMP_EVENT: return "F_TEMP_EVENT";
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";
default: return "Unknown Function";
}
@ -276,6 +293,8 @@ void function_table() {
flist[F_TEMP_CONTROL] = &temp_control;
flist[F_TEMP_EVENT] = &temp_event;
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
flist[F_STORAGE_CELL_START] = &storage_cell_start;
flist[F_CHECK_VERSION] = &check_version;
// check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@ -313,6 +332,21 @@ int M_nofunc(int file_des){
int M_nofuncMode(int file_des){
int ret=FAIL,ret1=FAIL;
int n=0;
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
strcat(mess, "On-board detector server in update mode. Restart detector server in normal mode (without any arguments) to continue.\n");
cprintf(BG_RED,"Error: %s",mess);
n = sendData(file_des,&ret1,sizeof(ret1),INT32);
n = sendData(file_des,mess,sizeof(mess),OTHER); // mess is defined at function call
// return ok / fail
return ret;
}
@ -2240,20 +2274,19 @@ int set_settings(int file_des) {
sprintf(mess,"set settings failed\n");
#ifdef MYTHEN3D
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Set Settings) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Set Settings) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
// receive arguments
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
imod=arg[1];
isett=arg[0];
imod=arg[1];
// execute action
if (differentClients && lockStatus && isett!=GET_SETTINGS) {
@ -2262,20 +2295,57 @@ int set_settings(int file_des) {
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else if (imod>=getTotalNumberOfModules()) {
#ifdef MYTHEND
if ( (ret != FAIL) && (imod>=getTotalNumberOfModules())) {
ret = FAIL;
sprintf(mess,"Module number %d out of range\n",imod);
cprintf(RED, "Warning: %s", mess);
}
else {
#endif
switch(isett) {
case GET_SETTINGS:
case UNINITIALIZED:
#ifdef JUNGFRAUD
case DYNAMICGAIN:
case DYNAMICHG0:
case FIXGAIN1:
case FIXGAIN2:
case FORCESWITCHG1:
case FORCESWITCHG2:
break;
default:
ret = FAIL;
sprintf(mess,"Setting (%d) is not implemented for this detector.\n"
"Options are dynamicgain, dynamichg0, fixgain1, fixgain2, "
"forceswitchg1 and forceswitchg2.\n", isett);
cprintf(RED, "Warning: %s", mess);
break;
// other detectors
// #elif GOTTHARDD, MOENCHD, PROPIXD
#else
break;
default:
ret = FAIL;
#ifdef EIGERD
sprintf(mess,"Cannot set settings via SET_SETTINGS, use SET_MODULE\n");
#else
sprintf(mess,"Setting (%d) is not implemented for this detector\n", isett);
#endif
cprintf(RED, "Warning: %s", mess);
break;
#endif
}
if (ret != FAIL) {
#ifdef VERBOSE
printf("Changing settings of module %d to %d\n", imod, isett);
printf("Changing settings of module %d to %d\n", imod, isett);
#endif
retval=setSettings(isett, imod);
#ifdef VERBOSE
printf("Settings changed to %d\n", isett);
#endif
if (retval==isett || isett<0) {
if (retval == isett || isett < 0) {
ret=OK;
} else {
ret = FAIL;
@ -2283,6 +2353,17 @@ int set_settings(int file_des) {
cprintf(RED, "Warning: %s", mess);
}
}
// set to default dacs,
//# also for #elif GOTTHARDD, MOENCHD, PROPIXD
#ifdef JUNGFRAUD
if (ret == OK && isett >= 0) {
ret = setDefaultDacs();
if (ret == FAIL) {
strcpy(mess,"Could change settings, but could not set to default dacs\n");
cprintf(RED, "Warning: %s", mess);
}
}
#endif
#endif
#endif
@ -2708,6 +2789,14 @@ int set_timer(int file_des) {
printf("setting timer %d to %lld ns\n",ind,tns);
#endif
switch(ind) {
#ifdef JUNGFRAUD
case STORAGE_CELL_NUMBER:
if (tns > MAX_STORAGE_CELL_VAL) {
ret=FAIL;
strcpy(mess,"Max Storage cell number should not exceed 15\n");
break;
}
#endif
#ifdef EIGERD
case SUBFRAME_ACQUISITION_TIME:
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
@ -2715,6 +2804,16 @@ int set_timer(int file_des) {
strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n");
break;
}
retval = setTimer(ind,tns);
break;
case SUBFRAME_PERIOD:
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
ret=FAIL;
strcpy(mess,"Sub Frame Period should not exceed 5.368 seconds\n");
break;
}
retval = setTimer(ind,tns);
break;
#endif
#ifdef MYTHEN
case PROBES_NUMBER:
@ -2740,6 +2839,8 @@ int set_timer(int file_des) {
cprintf(RED, "%s", mess);
break;
}
#if defined(MYTHEND) || defined(GOTTHARD)
if (ret == OK && ind==FRAME_NUMBER) {
ret=allocateRAM();
@ -2803,39 +2904,53 @@ int get_time_left(int file_des) {
printf("getting time left on timer %d \n",ind);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
switch(ind) {
#ifdef JUNGFRAUD
if (ind == DELAY_AFTER_TRIGGER) {
ret = FAIL;
sprintf(mess,"Timer Left Index (%d) is not implemented for this release.\n", (int)ind);
cprintf(RED, "%s", mess);
} else {
#endif
switch(ind) {
#ifdef MYTHEND
case PROBES_NUMBER:
case PROBES_NUMBER:
#elif JUNGFRAUD
case FRAMES_FROM_START:
case FRAMES_FROM_START_PG:
case FRAMES_FROM_START:
case FRAMES_FROM_START_PG:
#elif MYTHEN3D
case GATES_NUMBER:
case PROBES_NUMBER:
case SAMPLES_JCTB:
case GATES_NUMBER:
case PROBES_NUMBER:
case SAMPLES_JCTB:
#endif
#ifndef JUNGFRAUD
case GATES_NUMBER:
case GATES_NUMBER:
#endif
case FRAME_NUMBER:
case ACQUISITION_TIME:
case FRAME_PERIOD:
case DELAY_AFTER_TRIGGER:
case CYCLES_NUMBER:
case PROGRESS:
case ACTUAL_TIME:
case MEASUREMENT_TIME:
retval=getTimeLeft(ind);
break;
default:
ret = FAIL;
sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind);
cprintf(RED, "%s", mess);
break;
}
case FRAME_NUMBER:
case ACQUISITION_TIME:
case FRAME_PERIOD:
case DELAY_AFTER_TRIGGER:
case CYCLES_NUMBER:
case PROGRESS:
case ACTUAL_TIME:
case MEASUREMENT_TIME:
retval=getTimeLeft(ind);
break;
default:
ret = FAIL;
sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind);
cprintf(RED, "%s", mess);
break;
}
#ifdef VERBOSE
printf("Time left on timer %d is %lld\n",ind, retval);
printf("Time left on timer %d is %lld\n",ind, retval);
#endif
#ifdef JUNGFRAUD
} // end of if (ind == DELAY_AFTER_TRIGGER)
#endif
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
@ -3003,6 +3118,8 @@ int set_readout_flags(int file_des) {
case PARALLEL:
case NONPARALLEL:
case SAFE:
case SHOW_OVERFLOW:
case NOOVERFLOW:
#endif
retval=setReadOutFlags(arg);
break;
@ -3535,6 +3652,12 @@ int send_update(int file_des) {
#endif
n = sendData(file_des,&retval,sizeof(int64_t),INT64);
if (n < 0) return printSocketReadError();
#ifdef SLS_DETECTOR_FUNCTION_LIST
retval=setTimer(SUBFRAME_PERIOD,GET_FLAG);
#endif
n = sendData(file_des,&retval,sizeof(int64_t),INT64);
if (n < 0) return printSocketReadError();
#endif
@ -3679,7 +3802,10 @@ int configure_mac(int file_des) {
// change mac to hardware mac, (for 1 gbe) change ip to hardware ip
if (idetectormacadd != getDetectorMAC()){
printf("*************************************************\n");
printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),idetectormacadd);
printf("WARNING: actual detector mac address %llx does not match "
"the one from client %llx\n",
(long long unsigned int)getDetectorMAC(),
(long long unsigned int)idetectormacadd);
idetectormacadd = getDetectorMAC();
printf("WARNING: Matched detectormac to the hardware mac now\n");
printf("*************************************************\n");
@ -3737,7 +3863,7 @@ int configure_mac(int file_des) {
#ifdef EIGERD
char arg[2][50];
memset(arg,0,sizeof(arg));
sprintf(arg[0],"%llx",idetectormacadd);
sprintf(arg[0],"%llx",(long long unsigned int)idetectormacadd);
sprintf(arg[1],"%x",detipad);
n += sendData(file_des,arg,sizeof(arg),OTHER);
#endif
@ -4913,7 +5039,6 @@ int program_fpga(int file_des) {
int n=0;
sprintf(mess,"program FPGA failed\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
@ -4922,78 +5047,48 @@ int program_fpga(int file_des) {
sprintf(mess,"Function (Program FPGA) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
size_t filesize = 0;
size_t totalsize = 0;
size_t unitprogramsize = 0;
char* fpgasrc = NULL;
FILE* fp = NULL;
// receive arguments - filesize
n = receiveData(file_des,&filesize,sizeof(filesize),INT32);
if (n < 0) return printSocketReadError();
totalsize = filesize;
#ifdef VERY_VERBOSE
printf("\n\n Total size is:%d\n",totalsize);
#endif
// execute action
if (differentClients && lockStatus) {
ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
if (!debugflag) {
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret=FAIL;
sprintf(mess,"FPGA cannot be programmed in this mode. "
"Restart on-board detector server with -update for update mode to continue.\n");
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else {
//opening file pointer to flash and telling FPGA to not touch flash
if(startWritingFPGAprogram(&fp) != OK) {
ret=FAIL;
sprintf(mess,"Could not write to flash. Error at startup.\n");
cprintf(RED,"%s",mess);
printf("Programming FPGA...");
size_t filesize = 0;
size_t totalsize = 0;
size_t unitprogramsize = 0;
char* fpgasrc = NULL;
FILE* fp = NULL;
// receive arguments - filesize
n = receiveData(file_des,&filesize,sizeof(filesize),INT32);
if (n < 0) return printSocketReadError();
totalsize = filesize;
#ifdef VERY_VERBOSE
printf("\n\n Total size is:%d\n",totalsize);
#endif
// 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 {
//opening file pointer to flash and telling FPGA to not touch flash
if(startWritingFPGAprogram(&fp) != OK) {
ret=FAIL;
sprintf(mess,"Could not write to flash. Error at startup.\n");
cprintf(RED,"%s",mess);
}
//---------------- first ret ----------------
// 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);
}
//---------------- first ret ----------------
if(ret!=FAIL) {
//erasing flash
eraseFlash();
fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE);
}
//writing to flash part by part
while(ret != FAIL && filesize){
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
if(unitprogramsize > filesize) //less than 2mb
unitprogramsize = filesize;
#ifdef VERY_VERBOSE
printf("unit size to receive is:%d\n",unitprogramsize);
printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
#endif
//receive
n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER);
if (n < 0) return printSocketReadError();
if(!(unitprogramsize - filesize)){
fpgasrc[unitprogramsize]='\0';
filesize-=unitprogramsize;
unitprogramsize++;
}else
filesize-=unitprogramsize;
ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp);
//---------------- middle rets ----------------
//---------------- first ret ----------------
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
@ -5001,37 +5096,81 @@ int program_fpga(int file_des) {
// send return argument
if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER);
cprintf(RED,"Failure: Breaking out of program receiving\n");
}
//---------------- middle rets ----------------
//---------------- first ret ----------------
if(ret != FAIL){
//print progress
printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) );
fflush(stdout);
if(ret!=FAIL) {
//erasing flash
eraseFlash();
fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE);
}
//writing to flash part by part
while(ret != FAIL && filesize){
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
if(unitprogramsize > filesize) //less than 2mb
unitprogramsize = filesize;
#ifdef VERY_VERBOSE
printf("unit size to receive is:%d\n",unitprogramsize);
printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
#endif
//receive
n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER);
if (n < 0) return printSocketReadError();
if(!(unitprogramsize - filesize)){
fpgasrc[unitprogramsize]='\0';
filesize-=unitprogramsize;
unitprogramsize++;
}else
filesize-=unitprogramsize;
ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp);
//---------------- middle rets ----------------
// 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);
cprintf(RED,"Failure: Breaking out of program receiving\n");
}
//---------------- middle rets ----------------
if(ret != FAIL){
//print progress
printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) );
fflush(stdout);
}
}
printf("\n");
//closing file pointer to flash and informing FPGA
stopWritingFPGAprogram(fp);
//free resources
if(fpgasrc != NULL)
free(fpgasrc);
if(fp!=NULL)
fclose(fp);
#ifdef VERY_VERBOSE
printf("Done with program receiving command\n");
#endif
if (isControlServer) {
basictests(debugflag);
initControlServer();
}
}
printf("\n");
//closing file pointer to flash and informing FPGA
stopWritingFPGAprogram(fp);
//free resources
if(fpgasrc != NULL)
free(fpgasrc);
if(fp!=NULL)
fclose(fp);
#ifdef VERY_VERBOSE
printf("Done with program receiving command\n");
#endif
if (isControlServer)
basictests(debugflag);
init_detector(isControlServer);
}
#endif
if (ret==OK)
ret=FORCE_UPDATE;
}
#endif
// ret could be swapped during sendData
@ -5061,8 +5200,7 @@ int reset_fpga(int file_des) {
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Start Readout) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
sprintf(mess,"Function (Reset FPGA) is not implemented for this detector\n"); cprintf(RED, "%s", mess);
#else
// execute action
@ -5073,9 +5211,14 @@ int reset_fpga(int file_des) {
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else {
if (isControlServer)
basictests(debugflag);
initControlServer(isControlServer);
if (isControlServer) {
basictests(debugflag); // mapping of control server at lease
#ifdef JUNGFRAUD
if (debugflag != PROGRAMMING_MODE)
#endif
initControlServer();
}
else initStopServer(); //remapping of stop server
ret = FORCE_UPDATE;
}
#endif
@ -5516,8 +5659,6 @@ int auto_comp_disable(int file_des) {
sprintf(mess,"Function (Auto Comp Disable) is not yet implemented for this detector\n");
cprintf(RED, "%s", mess);
/* will be connected after teh fpga upgrade
// receive arguments
int arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT32);
@ -5550,7 +5691,6 @@ int auto_comp_disable(int file_des) {
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
*/
#endif
// ret could be swapped during sendData
@ -5567,3 +5707,167 @@ int auto_comp_disable(int file_des) {
return ret;
}
int storage_cell_start(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"storage cell start failed\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Storage cell start) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
// receive arguments
int arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
// execute action
if (differentClients && lockStatus && arg!=-1) {
ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else if (arg > MAX_STORAGE_CELL_VAL) {
ret=FAIL;
strcpy(mess,"Max Storage cell number should not exceed 15\n");
cprintf(RED, "Warning: %s", mess);
} else {
#ifdef VERBOSE
printf("Storage cell start to %d\n", arg);
#endif
retval=selectStoragecellStart(arg);
#ifdef VERBOSE
printf("Storage cell start: %d\n",retval);
#endif
if (retval==arg || arg<0) {
ret=OK;
} else {
sprintf(mess,"Storage cell start select failed, wrote %d but read %d\n", arg, retval);
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);
} else
n += sendData(file_des,&retval,sizeof(retval),INT32);
// return ok / fail
return ret;
}
int check_version(int file_des) {
int ret=OK,ret1=OK;
int n=0;
sprintf(mess,"check version failed\n");
#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(GOTTHARD)
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret=FAIL;
sprintf(mess,"Function (Check Version Compatibility) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
// receive arguments
int64_t arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT64);
if (n < 0) return printSocketReadError();
// execute action
#ifdef SLS_DETECTOR_FUNCTION_LIST
// check software- firmware compatibility and basic tests
if (isControlServer) {
#ifdef VERBOSE
printf("Checking software-firmware compatibility and basic test result\n");
#endif
// check if firmware check is done
if (!isFirmwareCheckDone()) {
usleep(3 * 1000 * 1000);
if (!isFirmwareCheckDone()) {
ret = FAIL;
strcpy(mess,"Firmware Software Compatibility Check (Server Initialization) "
"still not done done in server. Unexpected.\n");
cprintf(RED, "Warning: %s", mess);
}
}
// check firmware check result
if (ret == OK) {
char* firmware_message = NULL;
if (getFirmwareCheckResult(&firmware_message) == FAIL) {
ret = FAIL;
strcpy(mess, firmware_message);
cprintf(RED, "Warning: %s", mess);
}
}
}
if (ret == OK) {
#ifdef VERBOSE
printf("Checking versioning compatibility with value %d\n",arg);
#endif
int64_t client_requiredVersion = arg;
int64_t det_apiVersion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
int64_t det_version = getDetectorId(DETECTOR_SOFTWARE_VERSION);
// old client
if (det_apiVersion > client_requiredVersion) {
ret = FAIL;
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);
cprintf(RED, "Warning: %s", mess);
}
// old software
else if (client_requiredVersion > det_version) {
ret = FAIL;
sprintf(mess,"Detector SW Version: (0x%llx). "
"Client's detector SW API Version: (0x%llx). "
"Incompatible, update detector software!\n",
det_version, client_requiredVersion);
cprintf(RED, "Warning: %s", mess);
}
}
#endif
#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

@ -6,12 +6,14 @@
// initialization functions
int printSocketReadError();
void basictests(int);
void setModeFlag(int);
void basictests();
void init_detector(int);
int decode_function(int);
const char* getFunctionName(enum detFuncs func);
void function_table();
int M_nofunc(int);
int M_nofuncMode(int);
// functions called by client
int exec_command(int);
@ -92,5 +94,7 @@ int threshold_temp(int);
int temp_control(int);
int temp_event(int);
int auto_comp_disable(int);
int storage_cell_start(int);
int check_version(int);
#endif

View File

@ -15,24 +15,24 @@ receiverInterface::receiverInterface(MySocketTCP *socket):dataSocket(socket){}
receiverInterface::~receiverInterface(){
delete dataSocket;
}
receiverInterface::~receiverInterface(){}
int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = "";
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
return ret;
}
@ -42,14 +42,15 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){
char args[3][MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = "";
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
else
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
@ -60,16 +61,18 @@ int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_S
int receiverInterface::sendInt(int fnum, int &retval, int arg){
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = "";
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&arg,sizeof(arg));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret;
}
@ -78,15 +81,17 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
int receiverInterface::getInt(int fnum, int &retval){
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = "";
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret;
}
@ -95,16 +100,18 @@ int receiverInterface::getInt(int fnum, int &retval){
int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = "";
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&arg,sizeof(arg));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret;
}
@ -113,16 +120,18 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){
int64_t args[2];
char messs[MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL;
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(messs));
std::cout<< "Receiver returned error: " << mess << std::endl;
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
cprintf(RED, "Receiver returned error: %s", mess);
}
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret;
}
@ -132,15 +141,18 @@ int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], c
int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){
int args[2];
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = "";
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret;
}
@ -172,12 +184,13 @@ int receiverInterface::getLastClientIP(int fnum, char retval[]){
int receiverInterface::executeFunction(int fnum,char mess[]){
int ret = slsDetectorDefs::FAIL;
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
std::cout<< "Receiver returned error: " << mess << std::endl;
cprintf(RED, "Receiver returned error: %s", mess);
}
return ret;

View File

@ -8,7 +8,6 @@
#include "Global.h"
using namespace std;
class CondVar {
public:

View File

@ -4,7 +4,6 @@
#include "Global.h"
#include <string>
using namespace std;
class Single;
class ThreadPool;
@ -15,10 +14,10 @@ public:
Multi();
~Multi();
string executeCommand(int argc,char* argv[]);
std::string executeCommand(int argc,char* argv[]);
int printNumber(int inum);
string printString(string s);
std::string printString(std::string s);
char* printCharArray(char a[]);
int createThreadPool();

View File

@ -10,7 +10,7 @@
#include "Global.h"
using namespace std;
//
class Mutex
{

View File

@ -3,7 +3,7 @@
#include "Multi.h"
#include <string>
using namespace std;
//
class Single {
public:

View File

@ -6,16 +6,12 @@
#include <iostream>
#include <vector>
#include <errno.h>
#include <string.h>
#include <string>
#include <stdio.h>
#include "Global.h"
#include "sls_detector_defs.h"
#include <iostream>
#include <stdio.h>
using namespace std;
class slsDetector;
template<typename _Ret>
@ -109,8 +105,8 @@ private:
class SuperTask: public virtual slsDetectorDefs {
public:
SuperTask():
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0){};
~SuperTask(){};
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0),m19(0){};
virtual ~SuperTask(){};
protected:
/** Function signature defined
* First argument is Return type, the remaining are arguments
@ -121,18 +117,19 @@ protected:
func0_t <runStatus >* m4;
func1_t <int, int>* m5;
func1_t <int, double>* m6;
func1_t <string, string>* m7;
func1_t <std::string, std::string>* m7;
func1_t <detectorSettings, int>* m8;
func2_t <int, int,int>* m9;
func2_t <int, string,int>* m10;
func2_t <int, std::string,int>* m10;
func2_t <dacs_t, dacIndex,int>* m11;
func2_t <detectorSettings, detectorSettings,int>* m12;
func2_t <int64_t, timerIndex,int64_t>* m13;
func2_t <string, networkParameter,string>* m14;
func3_t <int64_t, timerIndex,int64_t,int>* m13;
func2_t <std::string, networkParameter,std::string>* m14;
func3_t <int, int,int,int>* m15;
func4_t <int, trimMode,int,int,int>* m16;
func4_t <int, int,int,detectorSettings,int>* m17;
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m18;
func1_t <int, portType>* m19;
};
class Task: public virtual SuperTask {
@ -146,20 +143,47 @@ public:
Task(func0_t <runStatus >* t): SuperTask(),fnum(4){m4 = t;};
Task(func1_t <int, int>* t): SuperTask(),fnum(5){m5 = t;};
Task(func1_t <int, double>* t): SuperTask(),fnum(6){m6 = t;};
Task(func1_t <string, string>* t): SuperTask(),fnum(7){m7 = t;};
Task(func1_t <std::string, std::string>* t): SuperTask(),fnum(7){m7 = t;};
Task(func1_t <detectorSettings, int>* t): SuperTask(),fnum(8){m8 = t;};
Task(func2_t <int, int,int>* t): SuperTask(),fnum(9){m9 = t;};
Task(func2_t <int, string,int>* t): SuperTask(),fnum(10){m10 = t;};
Task(func2_t <int, std::string,int>* t): SuperTask(),fnum(10){m10 = t;};
Task(func2_t <dacs_t, dacIndex,int>* t): SuperTask(),fnum(11){m11 = t;};
Task(func2_t <detectorSettings, detectorSettings,int>* t): SuperTask(),fnum(12){m12 = t;};
Task(func2_t <int64_t, timerIndex,int64_t>* t): SuperTask(),fnum(13){m13 = t;};
Task(func2_t <string, networkParameter,string>* t): SuperTask(),fnum(14){m14 = t;};
Task(func3_t <int64_t, timerIndex,int64_t,int>* t): SuperTask(),fnum(13){m13 = t;};
Task(func2_t <std::string, networkParameter,std::string>* t): SuperTask(),fnum(14){m14 = t;};
Task(func3_t <int, int,int,int>* t): SuperTask(),fnum(15){m15 = t;};
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(16){m16 = t;};
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(17){m17 = t;};
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(18){m18 = t;};
Task(func1_t <int, portType>* t): SuperTask(),fnum(19){m19 = t;};
~Task(){}
virtual ~Task(){
switch(fnum) {
case 1: delete m1; break;
case 2: delete m2; break;
case 3: delete m3; break;
case 4: delete m4; break;
case 5: delete m5; break;
case 6: delete m6; break;
case 7: delete m7; break;
case 8: delete m8; break;
case 9: delete m9; break;
case 10: delete m10; break;
case 11: delete m11; break;
case 12: delete m12; break;
case 13: delete m13; break;
case 14: delete m14; break;
case 15: delete m15; break;
case 16: delete m16; break;
case 17: delete m17; break;
case 18: delete m18; break;
case 19: delete m19; break;
default:
cprintf(RED, "Error: Task not defined. Abort!\n");
break;
}
};
void operator()(){
switch(fnum) {
@ -181,6 +205,7 @@ public:
case 16: (*m16)(); break;
case 17: (*m17)(); break;
case 18: (*m18)(); break;
case 19: (*m19)(); break;
default:
cprintf(RED, "Error: Task not defined. Abort!\n");
break;

View File

@ -1,6 +1,6 @@
#include "ThreadPool.h"
#include <pthread.h>
using namespace std;
ThreadPool::ThreadPool(int pool_size) : m_pool_size(pool_size){
#ifdef VERBOSE
cout << "Constructed ThreadPool of size " << m_pool_size << endl;

View File

@ -14,7 +14,7 @@
#include "CondVar.h"
#include "Global.h"
#include <semaphore.h>
using namespace std;
//
class ThreadPool