mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
WIP
This commit is contained in:
@ -60,7 +60,6 @@ int eiger_iodelay = 0;
|
||||
int eiger_photonenergy = 0;
|
||||
int eiger_dynamicrange = 0;
|
||||
int eiger_parallelmode = 0;
|
||||
int eiger_storeinmem = 0;
|
||||
int eiger_overflow32 = 0;
|
||||
int eiger_readoutspeed = 0;
|
||||
int eiger_triggermode = 0;
|
||||
@ -687,8 +686,7 @@ void setupDetector() {
|
||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||
eiger_photonenergy = DEFAULT_PHOTON_ENERGY;
|
||||
setParallelMode(DEFAULT_PARALLEL_MODE);
|
||||
setOverFlowMode(DEFAULT_READOUT_STOREINRAM_MODE);
|
||||
setStoreInRamMode(DEFAULT_READOUT_OVERFLOW32_MODE);
|
||||
setOverFlowMode(DEFAULT_READOUT_OVERFLOW32_MODE);
|
||||
setClockDivider(RUN_CLK, DEFAULT_CLK_SPEED); // clk_devider,half speed
|
||||
setIODelay(DEFAULT_IO_DELAY);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
@ -805,14 +803,6 @@ int setOverFlowMode(int mode) {
|
||||
|
||||
int getOverFlowMode() { return eiger_overflow32; }
|
||||
|
||||
void setStoreInRamMode(int mode) {
|
||||
mode = (mode == 0 ? 0 : 1);
|
||||
LOG(logINFO, ("Setting Store in Ram mode to %d\n", mode));
|
||||
eiger_storeinmem = mode;
|
||||
}
|
||||
|
||||
int getStoreInRamMode() { return eiger_storeinmem; }
|
||||
|
||||
/* parameters - timer */
|
||||
|
||||
int setStartingFrameNumber(uint64_t value) {
|
||||
@ -1118,37 +1108,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// trimbits
|
||||
unsigned int *tt;
|
||||
tt = Feb_Control_GetTrimbits();
|
||||
|
||||
// exclude gap pixels
|
||||
int ip = 0, ich = 0;
|
||||
for (int iy = 0; iy < 256; ++iy) {
|
||||
for (int ichip = 0; ichip < 4; ++ichip) {
|
||||
for (int ix = 0; ix < 256; ++iy) {
|
||||
myMod->chanregs[ich++] = tt[ip++];
|
||||
}
|
||||
if (ichip < 3) {
|
||||
ip++;
|
||||
ip++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// copy local module to myMod
|
||||
if (detectorModules) {
|
||||
if (copyModule(myMod, detectorModules) == FAIL)
|
||||
return FAIL;
|
||||
} else
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED) {
|
||||
return thisSettings;
|
||||
@ -2057,10 +2016,8 @@ int startStateMachine() {
|
||||
LOG(logINFO, ("Going to start acquisition\n"));
|
||||
Feb_Control_StartAcquisition();
|
||||
|
||||
if (!eiger_storeinmem) {
|
||||
LOG(logINFO, ("requesting images right after start\n"));
|
||||
ret = startReadOut();
|
||||
}
|
||||
LOG(logINFO, ("requesting images right after start\n"));
|
||||
ret = startReadOut();
|
||||
|
||||
// wait for acquisition start
|
||||
if (ret == OK) {
|
||||
@ -2382,16 +2339,6 @@ void readFrame(int *ret, char *mess) {
|
||||
}
|
||||
LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||
|
||||
if (eiger_storeinmem) {
|
||||
LOG(logINFO, ("requesting images after storing in memory\n"));
|
||||
if (startReadOut() == FAIL) {
|
||||
strcpy(mess, "Could not execute read image requests\n");
|
||||
LOG(logERROR, (mess));
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// wait for detector to send
|
||||
int isTransmitting = 1;
|
||||
while (isTransmitting) {
|
||||
|
@ -103,7 +103,6 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
|
||||
#define DEFAULT_DYNAMIC_RANGE (16)
|
||||
|
||||
#define DEFAULT_PARALLEL_MODE (1)
|
||||
#define DEFAULT_READOUT_STOREINRAM_MODE (0)
|
||||
#define DEFAULT_READOUT_OVERFLOW32_MODE (0)
|
||||
#define DEFAULT_CLK_SPEED (FULL_SPEED)
|
||||
#define DEFAULT_IO_DELAY (650)
|
||||
|
@ -945,23 +945,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
for (int idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
*((myMod->dacs) + idac) = dacValues[idac];
|
||||
}
|
||||
// check if all of them are not initialized
|
||||
int initialized = 0;
|
||||
for (int idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
initialized = 1;
|
||||
}
|
||||
if (initialized) {
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED)
|
||||
return thisSettings;
|
||||
|
@ -745,23 +745,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
for (int idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
*((myMod->dacs) + idac) = dacValues[idac];
|
||||
}
|
||||
// check if all of them are not initialized
|
||||
int initialized = 0;
|
||||
for (int idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
initialized = 1;
|
||||
}
|
||||
if (initialized) {
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED)
|
||||
return thisSettings;
|
||||
|
@ -600,16 +600,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
// copy local module to myMod
|
||||
if (detectorModules) {
|
||||
if (copyModule(myMod, detectorModules) == FAIL)
|
||||
return FAIL;
|
||||
} else
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
|
||||
|
||||
int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
|
||||
|
@ -24,7 +24,6 @@ int receiveData(int file_des, void *buf, int length, intType itype);
|
||||
int sendDataOnly(int file_des, void *buf, int length);
|
||||
int receiveDataOnly(int file_des, void *buf, int length);
|
||||
|
||||
int sendModule(int file_des, sls_detector_module *myMod);
|
||||
int receiveModule(int file_des, sls_detector_module *myMod);
|
||||
|
||||
/**
|
||||
|
@ -184,8 +184,6 @@ int setParallelMode(int mode);
|
||||
int getParallelMode();
|
||||
int setOverFlowMode(int mode);
|
||||
int getOverFlowMode();
|
||||
void setStoreInRamMode(int mode);
|
||||
int getStoreInRamMode();
|
||||
#endif
|
||||
#ifdef CHIPTESTBOARDD
|
||||
int setReadoutMode(enum readoutMode mode);
|
||||
@ -276,7 +274,6 @@ int64_t getMeasurementTime();
|
||||
// parameters - module, settings
|
||||
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(GOTTHARD2D))
|
||||
int setModule(sls_detector_module myMod, char *mess);
|
||||
int getModule(sls_detector_module *myMod);
|
||||
#endif
|
||||
#ifdef MYTHEN3D
|
||||
int setTrimbits(int *trimbits);
|
||||
|
@ -41,12 +41,10 @@ int get_adc(int);
|
||||
int write_register(int);
|
||||
int read_register(int);
|
||||
int set_module(int);
|
||||
int get_module(int);
|
||||
int set_settings(int);
|
||||
int get_threshold_energy(int);
|
||||
int start_acquisition(int);
|
||||
int stop_acquisition(int);
|
||||
int start_readout(int);
|
||||
int get_run_status(int);
|
||||
int start_and_read_all(int);
|
||||
int read_all(int);
|
||||
@ -85,7 +83,6 @@ int get_measurement_time(int);
|
||||
int set_dynamic_range(int);
|
||||
int set_roi(int);
|
||||
int get_roi(int);
|
||||
int exit_server(int);
|
||||
int lock_server(int);
|
||||
int get_last_client_ip(int);
|
||||
int set_port(int);
|
||||
@ -181,8 +178,6 @@ int set_parallel_mode(int);
|
||||
int get_parallel_mode(int);
|
||||
int set_overflow_mode(int);
|
||||
int get_overflow_mode(int);
|
||||
int set_storeinram(int);
|
||||
int get_storeinram(int);
|
||||
int set_readout_mode(int);
|
||||
int get_readout_mode(int);
|
||||
int set_clock_frequency(int);
|
||||
|
@ -404,68 +404,6 @@ int receiveDataOnly(int file_des, void *buf, int length) {
|
||||
return total_received;
|
||||
}
|
||||
|
||||
int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
int ts = 0, n = 0;
|
||||
n = sendData(file_des, &(myMod->serialnumber), sizeof(myMod->serialnumber),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->nchip), sizeof(myMod->nchip), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->ndac), sizeof(myMod->ndac), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->reg), sizeof(myMod->reg), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->iodelay), sizeof(myMod->iodelay), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->eV), sizeof(myMod->eV), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
// dacs
|
||||
n = sendData(file_des, myMod->dacs, sizeof(int) * (myMod->ndac), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
// channels
|
||||
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||
n = sendData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("module of size %d sent register %x\n", ts, myMod->reg));
|
||||
return ts;
|
||||
}
|
||||
|
||||
int receiveModule(int file_des, sls_detector_module *myMod) {
|
||||
enum TLogLevel level = logDEBUG1;
|
||||
LOG(level, ("Receiving Module\n"));
|
||||
|
@ -155,15 +155,12 @@ void function_table() {
|
||||
flist[F_WRITE_REGISTER] = &write_register;
|
||||
flist[F_READ_REGISTER] = &read_register;
|
||||
flist[F_SET_MODULE] = &set_module;
|
||||
flist[F_GET_MODULE] = &get_module;
|
||||
flist[F_SET_SETTINGS] = &set_settings;
|
||||
flist[F_GET_THRESHOLD_ENERGY] = &get_threshold_energy;
|
||||
flist[F_START_ACQUISITION] = &start_acquisition;
|
||||
flist[F_STOP_ACQUISITION] = &stop_acquisition;
|
||||
flist[F_START_READOUT] = &start_readout;
|
||||
flist[F_GET_RUN_STATUS] = &get_run_status;
|
||||
flist[F_START_AND_READ_ALL] = &start_and_read_all;
|
||||
flist[F_READ_ALL] = &read_all;
|
||||
flist[F_GET_NUM_FRAMES] = &get_num_frames;
|
||||
flist[F_SET_NUM_FRAMES] = &set_num_frames;
|
||||
flist[F_GET_NUM_TRIGGERS] = &get_num_triggers;
|
||||
@ -201,7 +198,6 @@ void function_table() {
|
||||
flist[F_SET_DYNAMIC_RANGE] = &set_dynamic_range;
|
||||
flist[F_SET_ROI] = &set_roi;
|
||||
flist[F_GET_ROI] = &get_roi;
|
||||
flist[F_EXIT_SERVER] = &exit_server;
|
||||
flist[F_LOCK_SERVER] = &lock_server;
|
||||
flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip;
|
||||
flist[F_SET_PORT] = &set_port;
|
||||
@ -292,8 +288,6 @@ void function_table() {
|
||||
flist[F_GET_PARALLEL_MODE] = &get_parallel_mode;
|
||||
flist[F_SET_OVERFLOW_MODE] = &set_overflow_mode;
|
||||
flist[F_GET_OVERFLOW_MODE] = &get_overflow_mode;
|
||||
flist[F_SET_STOREINRAM_MODE] = &set_storeinram;
|
||||
flist[F_GET_STOREINRAM_MODE] = &get_storeinram;
|
||||
flist[F_SET_READOUT_MODE] = &set_readout_mode;
|
||||
flist[F_GET_READOUT_MODE] = &get_readout_mode;
|
||||
flist[F_SET_CLOCK_FREQUENCY] = &set_clock_frequency;
|
||||
@ -1544,68 +1538,6 @@ int set_module(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_module(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
sls_detector_module module;
|
||||
int *myDac = NULL;
|
||||
int *myChan = NULL;
|
||||
module.dacs = NULL;
|
||||
module.chanregs = NULL;
|
||||
|
||||
// allocate to send arguments
|
||||
// allocate dacs
|
||||
myDac = malloc(getNumberOfDACs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfDACs() > 0 && myDac == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not allocate dacs\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
module.dacs = myDac;
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D)
|
||||
functionNotImplemented();
|
||||
#endif
|
||||
|
||||
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||
// allocate chans
|
||||
if (ret == OK) {
|
||||
myChan = malloc(getTotalNumberOfChannels() * sizeof(int));
|
||||
if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not allocate chans\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
module.chanregs = myChan;
|
||||
}
|
||||
#endif
|
||||
|
||||
// get module
|
||||
if (ret == OK) {
|
||||
module.nchip = getNumberOfChips();
|
||||
module.nchan = getTotalNumberOfChannels();
|
||||
module.ndac = getNumberOfDACs();
|
||||
|
||||
// only get
|
||||
LOG(logDEBUG1, ("Getting module\n"));
|
||||
#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
|
||||
getModule(&module);
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting module. Settings:%d\n", module.reg));
|
||||
}
|
||||
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
|
||||
// send module, 0 is to receive partially (without trimbits etc)
|
||||
if (ret != FAIL) {
|
||||
ret = sendModule(file_des, &module);
|
||||
}
|
||||
free(myChan);
|
||||
free(myDac);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int set_settings(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -1808,27 +1740,6 @@ int stop_acquisition(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int start_readout(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
LOG(logDEBUG1, ("Starting readout\n"));
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = startReadOut();
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not start readout\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
LOG(logDEBUG1, ("Starting readout ret: %d\n", ret));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_run_status(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -2793,14 +2704,6 @@ int get_roi(int file_des) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int exit_server(int file_des) {
|
||||
LOG(logINFORED, ("Closing Server\n"));
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
return GOODBYE;
|
||||
}
|
||||
|
||||
int lock_server(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -5327,11 +5230,11 @@ int get_dest_udp_port(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1, ("Getting destination porstore in ram moden"));
|
||||
LOG(logDEBUG1, ("Getting destination port"));
|
||||
|
||||
// get only
|
||||
retval = udpDetails.dstport;
|
||||
LOG(logDEBUG, ("udp destination port retstore in ram model: %u\n", retval));
|
||||
LOG(logDEBUG, ("udp destination port retval: %u\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
@ -5570,43 +5473,6 @@ int get_overflow_mode(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_storeinram(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting store in ram mode: %u\n", arg));
|
||||
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
setStoreInRamMode(arg);
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_storeinram(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
|
||||
LOG(logDEBUG1, ("Getting store in ram mode\n"));
|
||||
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getStoreInRamMode();
|
||||
LOG(logDEBUG1, ("store in ram mode retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_readout_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
Reference in New Issue
Block a user