mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
merge conflict fix
This commit is contained in:
@ -177,7 +177,7 @@ void Beb_AdjustIPChecksum(struct udp_header_type *ip) {
|
||||
ip->ip_header_checksum[1] = ip_checksum & 0xff;
|
||||
}
|
||||
|
||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
int Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
*top = 0;
|
||||
*master = 0;
|
||||
// mapping new memory to read master top module configuration
|
||||
@ -187,6 +187,7 @@ void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
// read data
|
||||
ret = Beb_Read32(csp0base, BEB_CONFIG_RD_OFST);
|
||||
@ -202,6 +203,7 @@ void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
// close file pointer
|
||||
Beb_close(fd, csp0base);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay) {
|
||||
@ -862,11 +864,17 @@ void Beb_ResetFrameNumber() {
|
||||
}
|
||||
|
||||
int Beb_SetUpTransferParameters(short the_bit_mode) {
|
||||
if (the_bit_mode != 4 && the_bit_mode != 8 && the_bit_mode != 16 &&
|
||||
the_bit_mode != 32)
|
||||
switch (the_bit_mode) {
|
||||
case 4:
|
||||
case 8:
|
||||
case 12:
|
||||
case 16:
|
||||
case 32:
|
||||
Beb_bit_mode = the_bit_mode;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
Beb_bit_mode = the_bit_mode;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int Beb_StopAcquisition() {
|
||||
|
@ -15,7 +15,7 @@ int Beb_SetHeaderData(uint64_t src_mac, uint32_t src_ip, uint16_t src_port,
|
||||
uint64_t dst_mac, uint32_t dst_ip, uint16_t dst_port);
|
||||
void Beb_AdjustIPChecksum(struct udp_header_type *ip);
|
||||
|
||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
||||
int Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
||||
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
|
||||
|
||||
void Beb_SetTopVariable(int val);
|
||||
|
@ -16,91 +16,31 @@ include_directories(
|
||||
../../slsSupportLib/include
|
||||
)
|
||||
|
||||
add_executable(eigerDetectorServerMaster_virtual
|
||||
add_executable(eigerDetectorServer_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerMaster_virtual
|
||||
target_include_directories(eigerDetectorServer_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerMaster_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
PUBLIC VIRTUAL_MASTER
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerMaster_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerMaster_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerMaster_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add_executable(eigerDetectorServerSlaveTop_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
PUBLIC VIRTUAL_TOP
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveTop_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlaveTop_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
add_executable(eigerDetectorServerSlaveBottom_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlaveBottom_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlaveBottom_virtual
|
||||
target_compile_definitions(eigerDetectorServer_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveBottom_virtual
|
||||
target_link_libraries(eigerDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES
|
||||
set_target_properties(eigerDetectorServer_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlaveBottom_virtual
|
||||
install(TARGETS eigerDetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY)
|
||||
configure_file(detid_eiger.txt ${CMAKE_BINARY_DIR}/bin/detid_eiger.txt COPYONLY)
|
||||
|
@ -18,7 +18,7 @@
|
||||
const unsigned int Feb_Control_leftAddress = 0x100;
|
||||
const unsigned int Feb_Control_rightAddress = 0x200;
|
||||
|
||||
int Feb_Control_master = 0;
|
||||
int Feb_Control_master = -1;
|
||||
int Feb_Control_normal = 0;
|
||||
int Feb_Control_activated = 1;
|
||||
|
||||
@ -50,17 +50,16 @@ double ratemax = -1;
|
||||
// setup
|
||||
void Feb_Control_activate(int activate) { Feb_Control_activated = activate; }
|
||||
|
||||
void Feb_Control_FebControl() {
|
||||
Feb_Control_staticBits = Feb_Control_acquireNReadoutMode =
|
||||
Feb_Control_triggerMode = Feb_Control_externalEnableMode =
|
||||
Feb_Control_subFrameMode = 0;
|
||||
int Feb_Control_FebControl(int normal) {
|
||||
Feb_Control_staticBits = 0;
|
||||
Feb_Control_acquireNReadoutMode = 0;
|
||||
Feb_Control_triggerMode = 0;
|
||||
Feb_Control_externalEnableMode = 0;
|
||||
Feb_Control_subFrameMode = 0;
|
||||
Feb_Control_trimbit_size = 263680;
|
||||
Feb_Control_last_downloaded_trimbits =
|
||||
malloc(Feb_Control_trimbit_size * sizeof(int));
|
||||
}
|
||||
|
||||
int Feb_Control_Init(int master, int normal) {
|
||||
Feb_Control_master = master;
|
||||
Feb_Control_normal = normal;
|
||||
Feb_Interface_SetAddress(Feb_Control_rightAddress, Feb_Control_leftAddress);
|
||||
if (Feb_Control_activated) {
|
||||
@ -931,7 +930,10 @@ unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec) {
|
||||
|
||||
int Feb_Control_PrepareForAcquisition() {
|
||||
LOG(logINFOBLUE, ("Preparing for Acquisition\n"));
|
||||
Feb_Control_PrintAcquisitionSetup();
|
||||
if (!Feb_Control_PrintAcquisitionSetup()) {
|
||||
LOG(logERROR, ("Could not prepare acquisition\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Feb_Control_Reset() == STATUS_ERROR) {
|
||||
LOG(logERROR, ("Trouble reseting daq or data stream\n"));
|
||||
@ -988,20 +990,26 @@ int Feb_Control_PrepareForAcquisition() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Feb_Control_PrintAcquisitionSetup() {
|
||||
int Feb_Control_PrintAcquisitionSetup() {
|
||||
time_t rawtime;
|
||||
time(&rawtime);
|
||||
struct tm *timeinfo = localtime(&rawtime);
|
||||
LOG(logINFO,
|
||||
("Starting an exposure: (%s)"
|
||||
"\t Dynamic range nbits: %d\n"
|
||||
"\t Trigger mode: 0x%x\n"
|
||||
"\t Number of exposures: %d\n"
|
||||
"\t Exsposure time (if used): %f seconds.\n"
|
||||
"\t Exsposure period (if used): %f seconds.\n\n",
|
||||
asctime(timeinfo), Feb_Control_GetDynamicRange(),
|
||||
Feb_Control_triggerMode, Feb_Control_GetNExposures(),
|
||||
Feb_Control_exposure_time_in_sec, Feb_Control_exposure_period_in_sec));
|
||||
int dr = 0;
|
||||
if (!Feb_Control_GetDynamicRange(&dr)) {
|
||||
LOG(logERROR, ("Could not print acquisition set up\n"));
|
||||
return 0;
|
||||
}
|
||||
LOG(logINFO, ("Starting an exposure: (%s)"
|
||||
"\t Dynamic range nbits: %d\n"
|
||||
"\t Trigger mode: 0x%x\n"
|
||||
"\t Number of exposures: %d\n"
|
||||
"\t Exsposure time (if used): %f seconds.\n"
|
||||
"\t Exsposure period (if used): %f seconds.\n\n",
|
||||
asctime(timeinfo), dr, Feb_Control_triggerMode,
|
||||
Feb_Control_GetNExposures(), Feb_Control_exposure_time_in_sec,
|
||||
Feb_Control_exposure_period_in_sec));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_StartAcquisition() {
|
||||
@ -1169,49 +1177,106 @@ int Feb_Control_SoftwareTrigger(int block) {
|
||||
}
|
||||
|
||||
// parameters
|
||||
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo) {
|
||||
int Feb_Control_SetDynamicRange(int dr) {
|
||||
static unsigned int everything_but_bit_mode = DAQ_STATIC_BIT_PROGRAM |
|
||||
DAQ_STATIC_BIT_CHIP_TEST |
|
||||
DAQ_STATIC_BIT_ROTEST;
|
||||
if (four_eight_sixteen_or_thirtytwo == 4) {
|
||||
switch (dr) {
|
||||
case 4:
|
||||
Feb_Control_staticBits =
|
||||
DAQ_STATIC_BIT_M4 |
|
||||
(Feb_Control_staticBits &
|
||||
everything_but_bit_mode); // leave test bits in currernt state
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else if (four_eight_sixteen_or_thirtytwo == 8) {
|
||||
break;
|
||||
case 8:
|
||||
Feb_Control_staticBits = DAQ_STATIC_BIT_M8 | (Feb_Control_staticBits &
|
||||
everything_but_bit_mode);
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else if (four_eight_sixteen_or_thirtytwo == 16) {
|
||||
break;
|
||||
case 12:
|
||||
case 16:
|
||||
Feb_Control_staticBits = DAQ_STATIC_BIT_M12 | (Feb_Control_staticBits &
|
||||
everything_but_bit_mode);
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else if (four_eight_sixteen_or_thirtytwo == 32) {
|
||||
|
||||
// disable 16 bit conversion if 12 bit mode (enable if 16 bit)
|
||||
if (!Feb_Control_Disable16bitConversion(dr == 12))
|
||||
return 0;
|
||||
break;
|
||||
case 32:
|
||||
Feb_Control_staticBits = DAQ_STATIC_BIT_M12 | (Feb_Control_staticBits &
|
||||
everything_but_bit_mode);
|
||||
Feb_Control_subFrameMode |= DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else {
|
||||
LOG(logERROR, ("dynamic range (%d) not valid, not setting bit mode.\n",
|
||||
four_eight_sixteen_or_thirtytwo));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("dynamic range (%d) not valid, not setting bit mode.\n", dr));
|
||||
LOG(logINFO, ("Set dynamic range int must equal 4,8 16, or 32.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG(logINFO,
|
||||
("Dynamic range set to %d\n", four_eight_sixteen_or_thirtytwo));
|
||||
LOG(logINFO, ("Dynamic range set to %d\n", dr));
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Feb_Control_GetDynamicRange() {
|
||||
if (Feb_Control_subFrameMode & DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING)
|
||||
return 32;
|
||||
else if (DAQ_STATIC_BIT_M4 & Feb_Control_staticBits)
|
||||
return 4;
|
||||
else if (DAQ_STATIC_BIT_M8 & Feb_Control_staticBits)
|
||||
return 8;
|
||||
int Feb_Control_GetDynamicRange(int *retval) {
|
||||
if (Feb_Control_subFrameMode & DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING) {
|
||||
*retval = 32;
|
||||
} else if (DAQ_STATIC_BIT_M4 & Feb_Control_staticBits) {
|
||||
*retval = 4;
|
||||
} else if (DAQ_STATIC_BIT_M8 & Feb_Control_staticBits) {
|
||||
*retval = 8;
|
||||
} else {
|
||||
int disable16 = 0;
|
||||
if (!Feb_Control_Get16bitConversionDisabled(&disable16)) {
|
||||
LOG(logERROR, ("Could not get dynamic range (12 or 16 bit)\n"));
|
||||
return 0;
|
||||
}
|
||||
if (disable16) {
|
||||
*retval = 12;
|
||||
} else {
|
||||
*retval = 16;
|
||||
}
|
||||
}
|
||||
|
||||
return 16;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_Disable16bitConversion(int disable) {
|
||||
LOG(logINFO, ("%s 16 bit expansion\n", disable ? "Disabling" : "Enabling"));
|
||||
unsigned int regval = 0;
|
||||
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
|
||||
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
|
||||
(disable ? "disable" : "enable")));
|
||||
return 0;
|
||||
}
|
||||
if (disable) {
|
||||
regval |= DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
|
||||
} else {
|
||||
regval &= ~DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
|
||||
}
|
||||
|
||||
if (!Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval)) {
|
||||
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
|
||||
(disable ? "disable" : "enable")));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_Get16bitConversionDisabled(int *ret) {
|
||||
unsigned int regval = 0;
|
||||
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
|
||||
LOG(logERROR, ("Could not get 16 bit expansion (bit mode)\n"));
|
||||
return 0;
|
||||
}
|
||||
if (regval & DAQ_REG_HRDWRE_DSBL_16BIT_MSK) {
|
||||
*ret = 1;
|
||||
} else {
|
||||
*ret = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed) {
|
||||
@ -1490,9 +1555,8 @@ int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Feb_Control_SetMasterVariable(int val) { Feb_Control_master = val; }
|
||||
|
||||
int Feb_Control_SetMaster(enum MASTERINDEX ind) {
|
||||
|
||||
uint32_t offset = DAQ_REG_HRDWRE;
|
||||
unsigned int addr[2] = {Feb_Control_leftAddress, Feb_Control_rightAddress};
|
||||
char *master_names[] = {MASTER_NAMES};
|
||||
@ -1529,9 +1593,31 @@ int Feb_Control_SetMaster(enum MASTERINDEX ind) {
|
||||
LOG(logINFOBLUE, ("%s Master flag to %s Feb\n",
|
||||
(ind == MASTER_HARDWARE ? "Resetting" : "Overwriting"),
|
||||
master_names[ind]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_SetMasterEffects(int master, int controlServer) {
|
||||
int prevMaster = Feb_Control_master;
|
||||
|
||||
Feb_Control_master = master;
|
||||
// change in master for 9m
|
||||
if (controlServer && prevMaster != Feb_Control_master &&
|
||||
!Feb_Control_normal) {
|
||||
if (prevMaster) {
|
||||
Feb_Control_CloseSerialCommunication();
|
||||
}
|
||||
if (Feb_Control_master) {
|
||||
if (!Feb_Control_OpenSerialCommunication()) {
|
||||
LOG(logERROR, ("Could not intitalize feb control serial "
|
||||
"communication\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Feb_Control_SetQuad(int val) {
|
||||
LOG(logINFO, ("Setting Quad to %d in Feb\n", val));
|
||||
Feb_Control_quadMode = val;
|
||||
@ -1554,7 +1640,10 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
|
||||
regval &= ~(DAQ_REG_HRDWRE_PROGRAM_MSK | DAQ_REG_HRDWRE_M8_MSK);
|
||||
}
|
||||
|
||||
return Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval);
|
||||
if (!Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval)) {
|
||||
LOG(logERROR, ("Could not set chip signals to trim quad\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1604,7 +1693,7 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
|
||||
for (int iloop = 0; iloop < 2; ++iloop) {
|
||||
if (run[iloop]) {
|
||||
LOG(logINFO,
|
||||
LOG(logDEBUG1,
|
||||
("Writing 0x%x to %s 0x%x\n", data, side[iloop], actualOffset));
|
||||
if (!Feb_Interface_WriteRegister(addr[iloop], actualOffset, data, 0,
|
||||
0)) {
|
||||
@ -1612,6 +1701,18 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
side[iloop], actualOffset));
|
||||
return 0;
|
||||
}
|
||||
uint32_t regVal = 0;
|
||||
if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
|
||||
®Val)) {
|
||||
LOG(logERROR, ("Could not read %s register\n", addr[iloop]));
|
||||
return 0;
|
||||
}
|
||||
if (regVal != data) {
|
||||
LOG(logERROR,
|
||||
("Could not write %s register. Write 0x%x, read 0x%x\n",
|
||||
addr[iloop], data, regVal));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1648,8 +1749,8 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
|
||||
side[iloop], actualOffset));
|
||||
return 0;
|
||||
}
|
||||
LOG(logINFO, ("Read 0x%x from %s 0x%x\n", value[iloop], side[iloop],
|
||||
actualOffset));
|
||||
LOG(logDEBUG1, ("Read 0x%x from %s 0x%x\n", value[iloop],
|
||||
side[iloop], actualOffset));
|
||||
*retval = value[iloop];
|
||||
// if not the other (left, not right OR right, not left), return the
|
||||
// value
|
||||
@ -1824,7 +1925,11 @@ int64_t Feb_Control_Get_RateTable_Period_in_nsec() {
|
||||
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec) {
|
||||
// period = exptime if 16bit, period = subexptime if 32 bit
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
int dr = 0;
|
||||
if (!Feb_Control_GetDynamicRange(&dr)) {
|
||||
LOG(logERROR, ("Could not set rate correction tau\n"));
|
||||
return 0;
|
||||
}
|
||||
double period_in_sec =
|
||||
(double)(Feb_Control_GetSubFrameExposureTime()) / (double)1e9;
|
||||
if (dr == 16)
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
// setup
|
||||
void Feb_Control_activate(int activate);
|
||||
void Feb_Control_FebControl();
|
||||
int Feb_Control_Init(int master, int normal);
|
||||
int Feb_Control_FebControl(int normal);
|
||||
int Feb_Control_OpenSerialCommunication();
|
||||
void Feb_Control_CloseSerialCommunication();
|
||||
int Feb_Control_CheckSetup();
|
||||
@ -55,7 +54,7 @@ int Feb_Control_ResetChipPartially();
|
||||
int Feb_Control_SendBitModeToBebServer();
|
||||
unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec);
|
||||
int Feb_Control_PrepareForAcquisition();
|
||||
void Feb_Control_PrintAcquisitionSetup();
|
||||
int Feb_Control_PrintAcquisitionSetup();
|
||||
int Feb_Control_StartAcquisition();
|
||||
int Feb_Control_StopAcquisition();
|
||||
int Feb_Control_IsReadyForTrigger(int *readyForTrigger);
|
||||
@ -63,8 +62,10 @@ int Feb_Control_SendSoftwareTrigger();
|
||||
int Feb_Control_SoftwareTrigger(int block);
|
||||
|
||||
// parameters
|
||||
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
|
||||
unsigned int Feb_Control_GetDynamicRange();
|
||||
int Feb_Control_SetDynamicRange(int dr);
|
||||
int Feb_Control_GetDynamicRange(int *retval);
|
||||
int Feb_Control_Disable16bitConversion(int disable);
|
||||
int Feb_Control_Get16bitConversionDisabled();
|
||||
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed);
|
||||
int Feb_Control_SetReadoutMode(unsigned int readout_mode);
|
||||
int Feb_Control_SetTriggerMode(unsigned int trigger_mode);
|
||||
@ -86,8 +87,8 @@ int Feb_Control_Get_Counter_Bit();
|
||||
int Feb_Control_SetInterruptSubframe(int val);
|
||||
int Feb_Control_GetInterruptSubframe();
|
||||
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
|
||||
void Feb_Control_SetMasterVariable(int val);
|
||||
int Feb_Control_SetMaster(enum MASTERINDEX ind);
|
||||
int Feb_Control_SetMasterEffects(int master, int controlServer);
|
||||
int Feb_Control_SetQuad(int val);
|
||||
int Feb_Control_SetChipSignalsToTrimQuad(int enable);
|
||||
int Feb_Control_SetReadNRows(int value);
|
||||
|
@ -29,6 +29,8 @@
|
||||
#define DAQ_REG_HRDWRE_OW_MASTER_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_MASTER_OFST)
|
||||
#define DAQ_REG_HRDWRE_MASTER_OFST (4)
|
||||
#define DAQ_REG_HRDWRE_MASTER_MSK (0x00000001 << DAQ_REG_HRDWRE_MASTER_OFST)
|
||||
#define DAQ_REG_HRDWRE_DSBL_16BIT_OFST (5)
|
||||
#define DAQ_REG_HRDWRE_DSBL_16BIT_MSK (0x00000001 << DAQ_REG_HRDWRE_DSBL_16BIT_OFST)
|
||||
#define DAQ_REG_HRDWRE_PROGRAM_OFST (30)
|
||||
#define DAQ_REG_HRDWRE_PROGRAM_MSK (0x00000001 << DAQ_REG_HRDWRE_PROGRAM_OFST)
|
||||
#define DAQ_REG_HRDWRE_M8_OFST (31)
|
||||
|
Binary file not shown.
@ -26,12 +26,17 @@ extern int updateFlag;
|
||||
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
|
||||
extern int numUdpDestinations;
|
||||
extern const enum detectorType myDetectorType;
|
||||
extern int ignoreConfigFileFlag;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char *cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char *cip, uint32_t ip);
|
||||
|
||||
// Variables that will be exported
|
||||
int masterCommandLine = -1;
|
||||
int topCommandLine = -1;
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -226,6 +231,23 @@ int getModuleId(int *ret, char *mess) {
|
||||
return getModuleIdInFile(ret, mess, ID_FILE);
|
||||
}
|
||||
|
||||
int updateModuleId() {
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
if (initError == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_module_id = modid;
|
||||
#else
|
||||
if (Beb_SetModuleId(modid) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, ("Could not get module id from the file"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
u_int64_t getDetectorMAC() {
|
||||
char mac[255] = "";
|
||||
u_int64_t res = 0;
|
||||
@ -305,46 +327,36 @@ u_int32_t getDetectorIP() {
|
||||
void initControlServer() {
|
||||
LOG(logINFOBLUE, ("Configuring Control server\n"));
|
||||
if (!updateFlag && initError == OK) {
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_module_id = modid;
|
||||
#endif
|
||||
if (initError == FAIL) {
|
||||
if (updateModuleConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
getModuleConfiguration();
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
// same addresses for top and bottom
|
||||
if (!Feb_Control_Init(master, normal)) {
|
||||
if (!Feb_Control_FebControl(normal)) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
||||
sprintf(initErrorMessage,
|
||||
"Could not intitalize eiger detector sever: feb control\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
// master of 9M, check high voltage serial communication to blackfin
|
||||
if (master && !normal) {
|
||||
if (!Feb_Control_OpenSerialCommunication()) {
|
||||
initError = FAIL;
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not intitalize feb control serial communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
if (Feb_Control_SetMasterEffects(master, isControlServer) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize HV for eiger "
|
||||
"detector server: feb control serial "
|
||||
"communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
Beb_SetTopVariable(top);
|
||||
Beb_Beb();
|
||||
Beb_SetModuleId(modid);
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
#endif
|
||||
// also reads config file and deactivates
|
||||
@ -354,73 +366,126 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
if (!updateFlag && initError == OK) {
|
||||
// wait a few s (control server is setting top/master from config file/
|
||||
// command line)
|
||||
usleep(WAIT_STOP_SERVER_START);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (updateModuleConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
getModuleConfiguration();
|
||||
sharedMemory_setStop(0);
|
||||
// get top/master in virtual
|
||||
readConfigFile();
|
||||
sharedMemory_setStop(0);
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
// force top or master if in command line
|
||||
if (checkCommandLineConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// wait a few s (control server is setting top/master from config file)
|
||||
usleep(WAIT_STOP_SERVER_START);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
// exit(-1);
|
||||
getModuleConfiguration();
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
// same addresses for top and bottom
|
||||
Feb_Control_Init(master, normal);
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
// control server read config file and already set up master/top
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Interface_FebInterface();
|
||||
if (!Feb_Control_FebControl(normal)) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
if (Feb_Control_SetMasterEffects(master, isControlServer) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize HV for eiger "
|
||||
"detector server: feb control serial "
|
||||
"communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
Beb_SetTopVariable(top);
|
||||
Beb_Beb();
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
#endif
|
||||
// client first connect (from shm) will activate
|
||||
if (setActivate(0) == FAIL) {
|
||||
LOG(logERROR, ("Could not deactivate in stop server\n"));
|
||||
// client first connect (from shm) will activate
|
||||
if (setActivate(0) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, "Could not deactivate\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
}
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
void getModuleConfiguration() {
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
void checkVirtual9MFlag() {
|
||||
#ifdef VIRTUAL
|
||||
#ifdef VIRTUAL_MASTER
|
||||
master = 1;
|
||||
top = 1;
|
||||
#else
|
||||
master = 0;
|
||||
#ifdef VIRTUAL_TOP
|
||||
top = 1;
|
||||
#else
|
||||
top = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VIRTUAL_9M
|
||||
normal = 0;
|
||||
#else
|
||||
normal = 1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
Beb_GetModuleConfiguration(&master, &top, &normal);
|
||||
int updateModuleConfiguration() {
|
||||
if (getModuleConfiguration(&master, &top, &normal) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
checkVirtual9MFlag();
|
||||
#endif
|
||||
if (isControlServer) {
|
||||
LOG(logINFOBLUE,
|
||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModuleConfiguration(int *m, int *t, int *n) {
|
||||
if (initError == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
*m = master;
|
||||
*t = top;
|
||||
*n = normal;
|
||||
#else
|
||||
if (Beb_GetModuleConfiguration(m, t, n) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, ("Could not get module configuration\n"));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logDEBUG,
|
||||
("module config read: master:%d top:%d normal:%d\n", *m, *t, *n));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
|
||||
if (initError == FAIL) {
|
||||
return initError;
|
||||
}
|
||||
master = -1;
|
||||
|
||||
if (ignoreConfigFileFlag) {
|
||||
LOG(logWARNING, ("Ignoring Config file\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// if not found in config file, they will be reset to hardware settings
|
||||
top = -1;
|
||||
master = -1;
|
||||
#endif
|
||||
|
||||
const int fileNameSize = 128;
|
||||
char fname[fileNameSize];
|
||||
@ -471,91 +536,54 @@ int readConfigFile() {
|
||||
|
||||
// top command
|
||||
if (!strncmp(line, "top", strlen("top"))) {
|
||||
int t = -1;
|
||||
// cannot scan values
|
||||
if (sscanf(line, "%s %d", command, &top) != 2) {
|
||||
if (sscanf(line, "%s %d", command, &t) != 2) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan top commands from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
enum TOPINDEX ind = (top == 1 ? OW_TOP : OW_BOTTOM);
|
||||
if (!Beb_SetTop(ind)) {
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not overwrite top to %d in Beb from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
top, line);
|
||||
if (t != 0 && t != 1) {
|
||||
sprintf(initErrorMessage,
|
||||
"Invalid top argument from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetTop(ind, 1, 1)) {
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not overwrite top to %d in Feb from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
top, line);
|
||||
sharedMemory_unlockLocalLink();
|
||||
if (setTop(t == 1 ? OW_TOP : OW_BOTTOM) == FAIL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not set top from config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
// validate change
|
||||
int actual_top = -1, temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&temp, &actual_top, &temp2);
|
||||
if (actual_top != top) {
|
||||
sprintf(initErrorMessage, "Could not set top to %d. Read %d\n",
|
||||
top, actual_top);
|
||||
break;
|
||||
}
|
||||
Beb_SetTopVariable(top);
|
||||
#endif
|
||||
}
|
||||
|
||||
// master command
|
||||
else if (!strncmp(line, "master", strlen("master"))) {
|
||||
int m = -1;
|
||||
// cannot scan values
|
||||
if (sscanf(line, "%s %d", command, &master) != 2) {
|
||||
if (sscanf(line, "%s %d", command, &m) != 2) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan master commands from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
enum MASTERINDEX ind = (master == 1 ? OW_MASTER : OW_SLAVE);
|
||||
if (!Beb_SetMaster(ind)) {
|
||||
if (m != 0 && m != 1) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not overwrite master to %d in Beb from on-board "
|
||||
"server "
|
||||
"Invalid master argument from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
master, line);
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetMaster(ind)) {
|
||||
if (setMaster(m == 1 ? OW_MASTER : OW_SLAVE) == FAIL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not overwrite master to %d in Feb from on-board "
|
||||
"server "
|
||||
"config file. Line:[%s].\n",
|
||||
master, line);
|
||||
sharedMemory_unlockLocalLink();
|
||||
"Could not set master from config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
// validate change
|
||||
int actual_master = -1, temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&actual_master, &temp, &temp2);
|
||||
if (actual_master != master) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not set master to %d. Read %d\n", master,
|
||||
actual_master);
|
||||
break;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
}
|
||||
|
||||
// other commands
|
||||
@ -576,8 +604,10 @@ int readConfigFile() {
|
||||
LOG(logINFO, ("Successfully read config file\n"));
|
||||
}
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// reset to hardware settings if not in config file (if overwritten)
|
||||
resetToHardwareSettings();
|
||||
#endif
|
||||
|
||||
return initError;
|
||||
}
|
||||
@ -589,55 +619,56 @@ void resetToHardwareSettings() {
|
||||
}
|
||||
// top not set in config file
|
||||
if (top == -1) {
|
||||
if (!Beb_SetTop(TOP_HARDWARE)) {
|
||||
LOG(logINFO, ("Resetting Top to hardware settings\n"));
|
||||
if (setTop(TOP_HARDWARE) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Top flag to Beb hardware settings.\n");
|
||||
"Could not reset Top flag to hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
return;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Top flag to Feb hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
int temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&temp, &top, &temp2);
|
||||
Beb_SetTopVariable(top);
|
||||
}
|
||||
// master not set in config file
|
||||
if (master == -1) {
|
||||
if (!Beb_SetMaster(TOP_HARDWARE)) {
|
||||
LOG(logINFO, ("Resetting Master to hardware settings\n"));
|
||||
if (setMaster(MASTER_HARDWARE) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Master flag to Beb hardware settings.\n");
|
||||
"Could not reset Master flag to hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
return;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Master flag to Feb hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
int temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&master, &temp, &temp2);
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
sharedMemory_unlockLocalLink();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int checkCommandLineConfiguration() {
|
||||
if (masterCommandLine != -1) {
|
||||
LOG(logINFO, ("Setting %s from Command Line\n",
|
||||
(masterCommandLine == 1 ? "Master" : "Slave")));
|
||||
if (setMaster(masterCommandLine == 1 ? OW_MASTER : OW_SLAVE) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not set %s from command line.\n",
|
||||
(masterCommandLine == 1 ? "Master" : "Slave"));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (topCommandLine != -1) {
|
||||
LOG(logINFO, ("Setting %s from Command Line\n",
|
||||
(topCommandLine == 1 ? "Top" : "Bottom")));
|
||||
if (setTop(topCommandLine == 1 ? OW_TOP : OW_BOTTOM) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not set %s from command line.\n",
|
||||
(topCommandLine == 1 ? "Top" : "Bottom"));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
|
||||
void allocateDetectorStructureMemory() {
|
||||
@ -671,15 +702,29 @@ void allocateDetectorStructureMemory() {
|
||||
}
|
||||
|
||||
void setupDetector() {
|
||||
|
||||
allocateDetectorStructureMemory();
|
||||
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL)
|
||||
return;
|
||||
// force top or master if in command line
|
||||
if (checkCommandLineConfiguration() == FAIL)
|
||||
return;
|
||||
|
||||
LOG(logINFOBLUE,
|
||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
|
||||
|
||||
if (updateModuleId() == FAIL)
|
||||
return;
|
||||
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
resetToDefaultDacs(0);
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStatus(IDLE);
|
||||
setupUDPCommParameters();
|
||||
#endif
|
||||
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
// setting default measurement parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setExpTime(DEFAULT_EXPTIME);
|
||||
@ -719,14 +764,6 @@ void setupDetector() {
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL) {
|
||||
return;
|
||||
}
|
||||
LOG(logINFOBLUE,
|
||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
|
||||
|
||||
if (setNumberofDestinations(numUdpDestinations) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, "Could not set number of udp destinations\n");
|
||||
@ -821,29 +858,38 @@ int readRegister(uint32_t offset, uint32_t *retval) {
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) {
|
||||
// setting dr
|
||||
if (dr > 0) {
|
||||
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return eiger_dynamicrange;
|
||||
}
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
eiger_dynamicrange = dr;
|
||||
if (dr <= 0) {
|
||||
return FAIL;
|
||||
}
|
||||
// getting dr
|
||||
#ifndef VIRTUAL
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
eiger_dynamicrange = Feb_Control_GetDynamicRange();
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return eiger_dynamicrange;
|
||||
}
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return eiger_dynamicrange;
|
||||
eiger_dynamicrange = dr;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
#ifdef VIRTUAL
|
||||
*retval = eiger_dynamicrange;
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_GetDynamicRange(retval)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* parameters - readout */
|
||||
@ -1158,6 +1204,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, set M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(1)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1170,6 +1217,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1179,6 +1227,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1450,7 +1499,120 @@ int setHighVoltage(int val) {
|
||||
|
||||
/* parameters - timing, extsig */
|
||||
|
||||
int isMaster() { return master; }
|
||||
int setMaster(enum MASTERINDEX m) {
|
||||
char *master_names[] = {MASTER_NAMES};
|
||||
LOG(logINFOBLUE, ("Setting up Master flag as %s\n", master_names[m]));
|
||||
#ifdef VIRTUAL
|
||||
switch (m) {
|
||||
case OW_MASTER:
|
||||
master = 1;
|
||||
break;
|
||||
case OW_SLAVE:
|
||||
master = 0;
|
||||
break;
|
||||
default:
|
||||
// hardware settings (do nothing)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// need to set it only once via the control server
|
||||
if (isControlServer) {
|
||||
if (!Beb_SetMaster(m)) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetMaster(m)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
}
|
||||
|
||||
// get and update master variable (cannot get from m, could be hardware)
|
||||
if (isMaster(&master) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
// verify for master and slave (not hardware)
|
||||
if ((m == OW_MASTER && master == 0) || (m == OW_SLAVE && master == 1)) {
|
||||
LOG(logERROR,
|
||||
("could not set master/slave. Master value retrieved %d\n",
|
||||
master));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// feb variable and hv comms (9m)
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetMasterEffects(master, isControlServer) == FAIL) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int isMaster(int *retval) {
|
||||
int m = -1, t = -1, n = -1;
|
||||
if (getModuleConfiguration(&m, &t, &n) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
*retval = m;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setTop(enum TOPINDEX t) {
|
||||
char *top_names[] = {TOP_NAMES};
|
||||
LOG(logINFOBLUE, ("Setting up Top flag as %s\n", top_names[t]));
|
||||
#ifdef VIRTUAL
|
||||
switch (t) {
|
||||
case OW_TOP:
|
||||
top = 1;
|
||||
break;
|
||||
case OW_BOTTOM:
|
||||
top = 0;
|
||||
break;
|
||||
default:
|
||||
// hardware settings (do nothing)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (!Beb_SetTop(t)) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetTop(t, 1, 1)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
|
||||
// get and update top variable(cannot get from t, could be hardware)
|
||||
if (isTop(&top) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
// verify for master and slave (not hardware)
|
||||
if ((t == OW_TOP && top == 0) || (t == OW_BOTTOM && top == 1)) {
|
||||
LOG(logERROR,
|
||||
("could not set top/bottom. Top value retrieved %d\n", top));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
Beb_SetTopVariable(top);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int isTop(int *retval) {
|
||||
int m = -1, t = -1, n = -1;
|
||||
if (getModuleConfiguration(&m, &t, &n) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
*retval = t;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setTiming(enum timingMode arg) {
|
||||
int ret = 0;
|
||||
@ -1923,7 +2085,8 @@ int setRateCorrection(
|
||||
else if (custom_tau_in_nsec == -1)
|
||||
custom_tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
int dr = eiger_dynamicrange;
|
||||
|
||||
// get period = subexptime if 32bit , else period = exptime if 16 bit
|
||||
int64_t actual_period =
|
||||
Feb_Control_GetSubFrameExposureTime(); // already in nsec
|
||||
@ -2321,7 +2484,7 @@ void *start_timer(void *arg) {
|
||||
const int maxRows = MAX_ROWS_PER_READOUT;
|
||||
const int packetsPerFrame = (maxPacketsPerFrame * readNRows) / maxRows;
|
||||
|
||||
LOG(logDEBUG1,
|
||||
LOG(logDEBUG,
|
||||
(" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n "
|
||||
"packetsize:%d\n maxnumpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, maxPacketsPerFrame,
|
||||
@ -2338,11 +2501,13 @@ void *start_timer(void *arg) {
|
||||
npixels /= 2;
|
||||
}
|
||||
LOG(logDEBUG1,
|
||||
("pixels:%d pixelsperpacket:%d\n", npixels, pixelsPerPacket));
|
||||
("npixels:%d pixelsperpacket:%d\n", npixels, pixelsPerPacket));
|
||||
uint8_t *src = (uint8_t *)imageData;
|
||||
for (int i = 0; i < npixels; ++i) {
|
||||
if (i > 0 && i % pixelsPerPacket == 0) {
|
||||
++pixelVal;
|
||||
}
|
||||
|
||||
switch (dr) {
|
||||
case 4:
|
||||
*((uint8_t *)(imageData + i)) =
|
||||
@ -2357,6 +2522,30 @@ void *start_timer(void *arg) {
|
||||
*((uint8_t *)(imageData + i)) =
|
||||
eiger_virtual_test_mode ? 0xFE : (uint8_t)pixelVal;
|
||||
break;
|
||||
case 12:
|
||||
if (eiger_virtual_test_mode) {
|
||||
// first 12 bit pixel
|
||||
// first 8 byte
|
||||
*src++ = 0xFE;
|
||||
// second 12bit pixel
|
||||
++i;
|
||||
// second 8 byte
|
||||
*src++ = 0xEF;
|
||||
// third byte
|
||||
*src++ = 0xFF;
|
||||
} else {
|
||||
// first 12 bit pixel
|
||||
// first 8 byte
|
||||
*src++ = (uint8_t)(i & 0xFF);
|
||||
// second 8 byte (first nibble)
|
||||
*src = (uint8_t)((i++ >> 8u) & 0xF);
|
||||
// second 12bit pixel
|
||||
// second 8 byte (second nibble)
|
||||
*src++ |= ((uint8_t)(i & 0xF) << 4u);
|
||||
// third byte
|
||||
*src++ = (uint8_t)((i >> 4u) & 0xFF);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
eiger_virtual_test_mode ? 0xFFE : (uint16_t)pixelVal;
|
||||
@ -2433,9 +2622,27 @@ void *start_timer(void *arg) {
|
||||
// fill data
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
{
|
||||
for (int psize = 0; psize < datasize; psize += npixelsx) {
|
||||
if (dr == 12) {
|
||||
// multiple of 768,1024,4096
|
||||
int copysize = 256;
|
||||
for (int psize = 0; psize < datasize; psize += copysize) {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset,
|
||||
copysize);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2,
|
||||
copysize);
|
||||
srcOffset += copysize;
|
||||
srcOffset2 += copysize;
|
||||
dstOffset += copysize;
|
||||
dstOffset2 += copysize;
|
||||
|
||||
// reached 1 row (quarter module)
|
||||
if ((srcOffset % npixelsx) == 0) {
|
||||
srcOffset += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int psize = 0; psize < datasize; psize += npixelsx) {
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset,
|
||||
imageData + srcOffset, npixelsx / 2);
|
||||
@ -2733,9 +2940,9 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
int calculateDataBytes() {
|
||||
if (send_to_ten_gig)
|
||||
return setDynamicRange(-1) * ONE_GIGA_CONSTANT * TEN_GIGA_BUFFER_SIZE;
|
||||
return eiger_dynamicrange * ONE_GIGA_CONSTANT * TEN_GIGA_BUFFER_SIZE;
|
||||
else
|
||||
return setDynamicRange(-1) * TEN_GIGA_CONSTANT * ONE_GIGA_BUFFER_SIZE;
|
||||
return eiger_dynamicrange * TEN_GIGA_CONSTANT * ONE_GIGA_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#define LINKED_SERVER_NAME "eigerDetectorServer"
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (29)
|
||||
#define REQUIRED_FIRMWARE_VERSION (30)
|
||||
// virtual ones renamed for consistency
|
||||
// real ones keep previous name for compatibility (already in production)
|
||||
#ifdef VIRTUAL
|
||||
|
Reference in New Issue
Block a user