mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
jf: timing info decoder (#987)
* timing_info_decoder command with options swissfel (default) and shine. added to python, command line generation, autocomplete, tostring, tests.
This commit is contained in:
@ -213,6 +213,9 @@
|
||||
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
|
||||
#define EXT_SYNC_OFST (4)
|
||||
#define EXT_SYNC_MSK (0x00000001 << EXT_SYNC_OFST)
|
||||
#define EXT_TIMING_INFO_DECODER_OFST (12)
|
||||
#define EXT_TIMING_INFO_DECODER_MSK (0x00000001 << EXT_TIMING_INFO_DECODER_OFST)
|
||||
|
||||
|
||||
/* Control Register */
|
||||
#define CONTROL_REG (0x4F << MEM_MAP_SHIFT)
|
||||
|
Binary file not shown.
@ -572,6 +572,7 @@ void setupDetector() {
|
||||
#endif
|
||||
setPedestalMode(DEFAULT_PEDESTAL_MODE, DEFAULT_PEDESTAL_FRAMES,
|
||||
DEFAULT_PEDESTAL_LOOPS);
|
||||
setTimingInfoDecoder(DEFAULT_TIMING_INFO_DECODER);
|
||||
setElectronCollectionMode(DEFAULT_ELECTRON_COLLECTION_MODE);
|
||||
}
|
||||
|
||||
@ -2616,6 +2617,41 @@ void setPedestalMode(int enable, uint8_t frames, uint16_t loops) {
|
||||
}
|
||||
}
|
||||
|
||||
int setTimingInfoDecoder(enum timingInfoDecoder val) {
|
||||
switch (val) {
|
||||
case SWISSFEL:
|
||||
LOG(logINFO, ("Setting Timing Info Decoder to SWISSFEL\n"));
|
||||
break;
|
||||
case SHINE:
|
||||
LOG(logINFO, ("Setting Timing Info Decoder to SHINE\n"));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown Timing Info Decoder %d\n", val));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int decodeValue = (int)val;
|
||||
uint32_t addr = EXT_SIGNAL_REG;
|
||||
bus_w(addr, bus_r(addr) & ~EXT_TIMING_INFO_DECODER_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((decodeValue << EXT_TIMING_INFO_DECODER_OFST) &
|
||||
EXT_TIMING_INFO_DECODER_MSK));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getTimingInfoDecoder(enum timingInfoDecoder *retval) {
|
||||
int decodeValue = ((bus_r(EXT_SIGNAL_REG) & EXT_TIMING_INFO_DECODER_MSK) >>
|
||||
EXT_TIMING_INFO_DECODER_OFST);
|
||||
if (decodeValue == (int)SWISSFEL) {
|
||||
*retval = SWISSFEL;
|
||||
} else if (decodeValue == (int)SHINE) {
|
||||
*retval = SHINE;
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getElectronCollectionMode() {
|
||||
return ((bus_r(DAQ_REG) & DAQ_ELCTRN_CLLCTN_MDE_MSK) >>
|
||||
DAQ_ELCTRN_CLLCTN_MDE_OFST);
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define MIN_REQRD_VRSN_T_RD_API 0x171220
|
||||
#define REQRD_FRMWRE_VRSN_BOARD2 0x230920 // 1.0 pcb (version = 010)
|
||||
#define REQRD_FRMWRE_VRSN 0x230921 // 2.0 pcb (version = 011)
|
||||
#define REQRD_FRMWRE_VRSN_BOARD2 0x241001 // 1.0 pcb (version = 010)
|
||||
#define REQRD_FRMWRE_VRSN 0x241001 // 2.0 pcb (version = 011)
|
||||
|
||||
#define NUM_HARDWARE_VERSIONS (2)
|
||||
#define HARDWARE_VERSION_NUMBERS \
|
||||
@ -59,6 +59,7 @@
|
||||
#define DEFAULT_PEDESTAL_MODE (0)
|
||||
#define DEFAULT_PEDESTAL_FRAMES (1)
|
||||
#define DEFAULT_PEDESTAL_LOOPS (1)
|
||||
#define DEFAULT_TIMING_INFO_DECODER (SWISSFEL)
|
||||
#define DEFAULT_ELECTRON_COLLECTION_MODE (0)
|
||||
|
||||
#define HIGHVOLTAGE_MIN (60)
|
||||
|
Binary file not shown.
@ -607,6 +607,8 @@ uint64_t getSelectCurrentSource();
|
||||
int getPedestalMode();
|
||||
void getPedestalParameters(uint8_t *frames, uint16_t *loops);
|
||||
void setPedestalMode(int enable, uint8_t frames, uint16_t loops);
|
||||
int setTimingInfoDecoder(enum timingInfoDecoder val);
|
||||
int getTimingInfoDecoder(enum timingInfoDecoder *retval);
|
||||
int getElectronCollectionMode();
|
||||
void setElectronCollectionMode(int enable);
|
||||
#endif
|
||||
|
@ -330,5 +330,7 @@ int setColumn(int);
|
||||
int get_pedestal_mode(int);
|
||||
int set_pedestal_mode(int);
|
||||
int config_transceiver(int);
|
||||
int get_timing_info_decoder(int);
|
||||
int set_timing_info_decoder(int);
|
||||
int get_collection_mode(int);
|
||||
int set_collection_mode(int);
|
||||
|
@ -492,6 +492,8 @@ void function_table() {
|
||||
flist[F_GET_PEDESTAL_MODE] = &get_pedestal_mode;
|
||||
flist[F_SET_PEDESTAL_MODE] = &set_pedestal_mode;
|
||||
flist[F_CONFIG_TRANSCEIVER] = &config_transceiver;
|
||||
flist[F_GET_TIMING_INFO_DECODER] = &get_timing_info_decoder;
|
||||
flist[F_SET_TIMING_INFO_DECODER] = &set_timing_info_decoder;
|
||||
flist[F_GET_COLLECTION_MODE] = &get_collection_mode;
|
||||
flist[F_SET_COLLECTION_MODE] = &set_collection_mode;
|
||||
|
||||
@ -11092,6 +11094,73 @@ int config_transceiver(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_timing_info_decoder(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
enum timingInfoDecoder retval = SWISSFEL;
|
||||
|
||||
LOG(logDEBUG1, ("Getting timing info decoder\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
ret = getTimingInfoDecoder(&retval);
|
||||
LOG(logDEBUG1, ("retval timing info decoder: %d\n", retval));
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get timing info decoder\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_timing_info_decoder(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
enum timingInfoDecoder arg = SWISSFEL;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting timing info decoder: %u\n", (int)arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
switch (arg) {
|
||||
case SWISSFEL:
|
||||
case SHINE:
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Timing info decoder index", (int)arg);
|
||||
break;
|
||||
}
|
||||
if (ret == OK) {
|
||||
ret = setTimingInfoDecoder(arg);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set timing info decoder\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
enum timingInfoDecoder retval = SWISSFEL;
|
||||
ret = getTimingInfoDecoder(&retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get timing info decoder\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1,
|
||||
("timing info decoder retval: %u\n", retval));
|
||||
validate(&ret, mess, (int)arg, (int)retval,
|
||||
"set timing info decoder", DEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_collection_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -11123,30 +11192,23 @@ int set_collection_mode(int file_des) {
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (getChipVersion() == 11) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Cannot set addl. number of storage cells for chip v1.1\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
switch (arg) {
|
||||
case HOLE:
|
||||
setElectronCollectionMode(0);
|
||||
break;
|
||||
case ELECTRON:
|
||||
setElectronCollectionMode(1);
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Collection mode index", (int)arg);
|
||||
break;
|
||||
}
|
||||
enum collectionMode retval =
|
||||
getElectronCollectionMode() ? ELECTRON : HOLE;
|
||||
validate(&ret, mess, (int)arg, (int)retval, "set collection mode",
|
||||
DEC);
|
||||
LOG(logDEBUG1, ("collection mode retval: %u\n", retval));
|
||||
switch (arg) {
|
||||
case HOLE:
|
||||
setElectronCollectionMode(0);
|
||||
break;
|
||||
case ELECTRON:
|
||||
setElectronCollectionMode(1);
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Collection mode index", (int)arg);
|
||||
break;
|
||||
}
|
||||
enum collectionMode retval =
|
||||
getElectronCollectionMode() ? ELECTRON : HOLE;
|
||||
validate(&ret, mess, (int)arg, (int)retval, "set collection mode",
|
||||
DEC);
|
||||
LOG(logDEBUG1, ("collection mode retval: %u\n", retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user